Skip to content
This repository was archived by the owner on Oct 19, 2022. It is now read-only.

Commit f90537c

Browse files
authored
fix: types again (#145)
Make duplex streams accept buffer lists as well as uint8arrays and fix final few uses of AbortOptions.
1 parent 4956a18 commit f90537c

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

Diff for: src/handle.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const log = Object.assign(debug('mss:handle'), {
1212
})
1313

1414
/**
15-
* @typedef {import('./types').DuplexStream<Uint8Array>} DuplexStream
15+
* @typedef {import('./types').DuplexStream<Uint8Array | BufferList>} DuplexStream
1616
* @typedef {import('./types').AbortOptions} AbortOptions
1717
*/
1818

Diff for: src/index.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ const { PROTOCOL_ID } = require('./constants')
88
exports.PROTOCOL_ID = PROTOCOL_ID
99

1010
/**
11-
* @typedef {import('./types').DuplexStream<Uint8Array>} DuplexStream
11+
* @typedef {import('bl/BufferList')} BufferList
12+
* @typedef {import('./types').DuplexStream<Uint8Array | BufferList>} DuplexStream
1213
* @typedef {import('./types').AbortOptions} AbortOptions
1314
*/
1415

@@ -24,8 +25,7 @@ class MultistreamSelect {
2425
/**
2526
* Perform the multistream-select handshake
2627
*
27-
* @param {object} [options]
28-
* @param {AbortSignal} options.signal
28+
* @param {AbortOptions} [options]
2929
*/
3030
async _handshake (options) {
3131
if (this._shaken) return
@@ -38,16 +38,14 @@ class MultistreamSelect {
3838
class Dialer extends MultistreamSelect {
3939
/**
4040
* @param {string | string[]} protocols
41-
* @param {object} [options]
42-
* @param {AbortSignal} options.signal
41+
* @param {AbortOptions} [options]
4342
*/
4443
select (protocols, options) {
4544
return select(this._stream, protocols, this._shaken ? undefined : PROTOCOL_ID, options)
4645
}
4746

4847
/**
49-
* @param {object} [options]
50-
* @param {AbortSignal} options.signal
48+
* @param {AbortOptions} [options]
5149
*/
5250
async ls (options) {
5351
await this._handshake(options)

Diff for: src/ls.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ const log = Object.assign(debug('mss:ls'), {
1414
})
1515

1616
/**
17-
* @typedef {import('./types').DuplexStream<Uint8Array>} DuplexStream
1817
* @typedef {import('bl/BufferList')} BufferList
18+
* @typedef {import('./types').DuplexStream<Uint8Array | BufferList>} DuplexStream
1919
* @typedef {import('./types').AbortOptions} AbortOptions
2020
*/
2121

Diff for: src/select.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ const log = Object.assign(debug('mss:select'), {
1111
})
1212

1313
/**
14-
* @typedef {import('./types').DuplexStream<Uint8Array>} DuplexStream
1514
* @typedef {import('bl/BufferList')} BufferList
15+
* @typedef {import('./types').DuplexStream<Uint8Array | BufferList>} DuplexStream
1616
* @typedef {import('./types').AbortOptions} AbortOptions
1717
*/
1818

0 commit comments

Comments
 (0)