Skip to content

Commit

Permalink
chore: workaround coveralls limitation
Browse files Browse the repository at this point in the history
  • Loading branch information
Gozala committed Jul 31, 2020
1 parent 4bb8e3e commit 759580c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packages/it-to-browser-readablestream/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,23 @@
// @ts-ignore
const globalThis = require('@ungap/global-this')

/**
* @typedef {Object} SourceExt
* @property {boolean} [_cancelled]
*/
/**
* @template T
* @typedef {SourceExt & UnderlyingSource<T>} Source
*/

/**
* @template T
* @param {AsyncIterator<T>|Iterator<T>} source
* @param {QueuingStrategy<T>} [queuingStrategy]
* @returns {ReadableStream<T>}
*/
function itToBrowserReadableStream (source, queuingStrategy = {}) {
/** @type {UnderlyingSource<T> & { _cancelled:boolean} } */
const pump = {
return new globalThis.ReadableStream(/** @type {Source<T>} */({
_cancelled: false,
async start () {
this._cancelled = false
Expand All @@ -38,9 +46,7 @@ function itToBrowserReadableStream (source, queuingStrategy = {}) {
cancel () {
this._cancelled = true
}
}

return new globalThis.ReadableStream(pump, queuingStrategy)
}), queuingStrategy)
}

module.exports = itToBrowserReadableStream

0 comments on commit 759580c

Please sign in to comment.