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

Commit

Permalink
fix: types again (#145)
Browse files Browse the repository at this point in the history
Make duplex streams accept buffer lists as well as uint8arrays and fix final few uses of AbortOptions.
  • Loading branch information
achingbrain committed Dec 21, 2021
1 parent 4956a18 commit f90537c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/handle.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const log = Object.assign(debug('mss:handle'), {
})

/**
* @typedef {import('./types').DuplexStream<Uint8Array>} DuplexStream
* @typedef {import('./types').DuplexStream<Uint8Array | BufferList>} DuplexStream
* @typedef {import('./types').AbortOptions} AbortOptions
*/

Expand Down
12 changes: 5 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const { PROTOCOL_ID } = require('./constants')
exports.PROTOCOL_ID = PROTOCOL_ID

/**
* @typedef {import('./types').DuplexStream<Uint8Array>} DuplexStream
* @typedef {import('bl/BufferList')} BufferList
* @typedef {import('./types').DuplexStream<Uint8Array | BufferList>} DuplexStream
* @typedef {import('./types').AbortOptions} AbortOptions
*/

Expand All @@ -24,8 +25,7 @@ class MultistreamSelect {
/**
* Perform the multistream-select handshake
*
* @param {object} [options]
* @param {AbortSignal} options.signal
* @param {AbortOptions} [options]
*/
async _handshake (options) {
if (this._shaken) return
Expand All @@ -38,16 +38,14 @@ class MultistreamSelect {
class Dialer extends MultistreamSelect {
/**
* @param {string | string[]} protocols
* @param {object} [options]
* @param {AbortSignal} options.signal
* @param {AbortOptions} [options]
*/
select (protocols, options) {
return select(this._stream, protocols, this._shaken ? undefined : PROTOCOL_ID, options)
}

/**
* @param {object} [options]
* @param {AbortSignal} options.signal
* @param {AbortOptions} [options]
*/
async ls (options) {
await this._handshake(options)
Expand Down
2 changes: 1 addition & 1 deletion src/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const log = Object.assign(debug('mss:ls'), {
})

/**
* @typedef {import('./types').DuplexStream<Uint8Array>} DuplexStream
* @typedef {import('bl/BufferList')} BufferList
* @typedef {import('./types').DuplexStream<Uint8Array | BufferList>} DuplexStream
* @typedef {import('./types').AbortOptions} AbortOptions
*/

Expand Down
2 changes: 1 addition & 1 deletion src/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ const log = Object.assign(debug('mss:select'), {
})

/**
* @typedef {import('./types').DuplexStream<Uint8Array>} DuplexStream
* @typedef {import('bl/BufferList')} BufferList
* @typedef {import('./types').DuplexStream<Uint8Array | BufferList>} DuplexStream
* @typedef {import('./types').AbortOptions} AbortOptions
*/

Expand Down

0 comments on commit f90537c

Please sign in to comment.