bare-stream
Advanced tools
Comparing version
@@ -118,3 +118,3 @@ const stream = require('streamx') | ||
if (cb) this.once('end', () => cb(null)) | ||
if (cb) this.once('finish', () => cb(null)) | ||
@@ -209,3 +209,3 @@ return result | ||
if (cb) this.once('end', () => cb(null)) | ||
if (cb) this.once('finish', () => cb(null)) | ||
@@ -292,3 +292,3 @@ return result | ||
if (cb) this.once('end', () => cb(null)) | ||
if (cb) this.once('finish', () => cb(null)) | ||
@@ -295,0 +295,0 @@ return result |
{ | ||
"name": "bare-stream", | ||
"version": "2.6.5", | ||
"version": "2.7.0", | ||
"description": "Streaming data for JavaScript", | ||
@@ -12,3 +12,6 @@ "exports": { | ||
"./promises": "./promises.js", | ||
"./web": "./web.js", | ||
"./web": { | ||
"types": "./web.d.ts", | ||
"default": "./web.js" | ||
}, | ||
"./global": "./global.js" | ||
@@ -21,2 +24,3 @@ }, | ||
"web.js", | ||
"web.d.ts", | ||
"global.js" | ||
@@ -23,0 +27,0 @@ ], |
24
web.js
const { Readable, getStreamError, isStreamx, isDisturbed } = require('streamx') | ||
const readableKind = Symbol.for('bare.stream.readable.kind') | ||
// https://streams.spec.whatwg.org/#readablestreamdefaultreader | ||
@@ -99,3 +101,7 @@ exports.ReadableStreamDefaultReader = class ReadableStreamDefaultReader { | ||
// https://streams.spec.whatwg.org/#readablestream | ||
exports.ReadableStream = class ReadableStream { | ||
class ReadableStream { | ||
static get [readableKind]() { | ||
return 0 // Compatibility version | ||
} | ||
constructor(underlyingSource = {}, queuingStrategy) { | ||
@@ -126,2 +132,6 @@ if (isStreamx(underlyingSource)) { | ||
get [readableKind]() { | ||
return ReadableStream[readableKind] | ||
} | ||
getReader() { | ||
@@ -180,2 +190,4 @@ return new exports.ReadableStreamDefaultReader(this) | ||
exports.ReadableStream = ReadableStream | ||
// https://streams.spec.whatwg.org/#countqueuingstrategy | ||
@@ -207,2 +219,12 @@ exports.CountQueuingStrategy = class CountQueuingStrategy { | ||
exports.isReadableStream = function isReadableStream(value) { | ||
if (value instanceof ReadableStream) return true | ||
return ( | ||
typeof value === 'object' && | ||
value !== null && | ||
value[readableKind] === ReadableStream[readableKind] | ||
) | ||
} | ||
// https://streams.spec.whatwg.org/#is-readable-stream-disturbed | ||
@@ -209,0 +231,0 @@ exports.isReadableStreamDisturbed = function isReadableStreamDisturbed(stream) { |
33358
7.65%9
12.5%702
11.08%