readable-stream
Advanced tools
Comparing version 4.1.0 to 4.2.0
@@ -5,2 +5,4 @@ 'use strict' | ||
const { Buffer } = require('buffer') | ||
const { inspect } = require('../../ours/util') | ||
@@ -7,0 +9,0 @@ |
'use strict' | ||
/* replacement start */ | ||
const process = require('process') | ||
/* replacement end */ | ||
const { | ||
@@ -316,3 +321,3 @@ aggregateTwoErrors, | ||
} else if (err) { | ||
process.nextTick(emitErrorCloseLegacy, stream) | ||
process.nextTick(emitErrorCloseLegacy, stream, err) | ||
} else { | ||
@@ -319,0 +324,0 @@ process.nextTick(emitCloseLegacy, stream) |
@@ -77,12 +77,41 @@ // Copyright Joyent, Inc. and other Node contributors. | ||
ObjectDefineProperties(Duplex.prototype, { | ||
writable: ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writable'), | ||
writableHighWaterMark: ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableHighWaterMark'), | ||
writableObjectMode: ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableObjectMode'), | ||
writableBuffer: ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableBuffer'), | ||
writableLength: ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableLength'), | ||
writableFinished: ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableFinished'), | ||
writableCorked: ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableCorked'), | ||
writableEnded: ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableEnded'), | ||
writableNeedDrain: ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableNeedDrain'), | ||
writable: { | ||
__proto__: null, | ||
...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writable') | ||
}, | ||
writableHighWaterMark: { | ||
__proto__: null, | ||
...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableHighWaterMark') | ||
}, | ||
writableObjectMode: { | ||
__proto__: null, | ||
...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableObjectMode') | ||
}, | ||
writableBuffer: { | ||
__proto__: null, | ||
...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableBuffer') | ||
}, | ||
writableLength: { | ||
__proto__: null, | ||
...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableLength') | ||
}, | ||
writableFinished: { | ||
__proto__: null, | ||
...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableFinished') | ||
}, | ||
writableCorked: { | ||
__proto__: null, | ||
...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableCorked') | ||
}, | ||
writableEnded: { | ||
__proto__: null, | ||
...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableEnded') | ||
}, | ||
writableNeedDrain: { | ||
__proto__: null, | ||
...ObjectGetOwnPropertyDescriptor(Writable.prototype, 'writableNeedDrain') | ||
}, | ||
destroyed: { | ||
__proto__: null, | ||
get() { | ||
@@ -89,0 +118,0 @@ if (this._readableState === undefined || this._writableState === undefined) { |
@@ -1,3 +0,7 @@ | ||
'use strict' | ||
/* replacement start */ | ||
const process = require('process') | ||
/* replacement end */ | ||
;('use strict') | ||
const bufferModule = require('buffer') | ||
@@ -4,0 +8,0 @@ |
@@ -0,5 +1,9 @@ | ||
/* replacement start */ | ||
const process = require('process') | ||
/* replacement end */ | ||
// Ported from https://github.com/mafintosh/end-of-stream with | ||
// permission from the author, Mathias Buus (@mafintosh). | ||
'use strict' | ||
;('use strict') | ||
const { AbortError, codes } = require('../../ours/errors') | ||
@@ -9,3 +13,3 @@ | ||
const { once } = require('../../ours/util') | ||
const { kEmptyObject, once } = require('../../ours/util') | ||
@@ -41,5 +45,5 @@ const { validateAbortSignal, validateFunction, validateObject } = require('../validators') | ||
callback = options | ||
options = {} | ||
options = kEmptyObject | ||
} else if (options == null) { | ||
options = {} | ||
options = kEmptyObject | ||
} else { | ||
@@ -46,0 +50,0 @@ validateObject(options, 'options') |
'use strict' | ||
/* replacement start */ | ||
const process = require('process') | ||
/* replacement end */ | ||
const { PromisePrototypeThen, SymbolAsyncIterator, SymbolIterator } = require('../../ours/primordials') | ||
const { Buffer } = require('buffer') | ||
const { ERR_INVALID_ARG_TYPE, ERR_STREAM_NULL_VALUES } = require('../../ours/errors').codes | ||
@@ -6,0 +13,0 @@ |
@@ -37,2 +37,3 @@ // LazyTransform is a special type of Transform stream that is lazily loaded. | ||
ObjectDefineProperty(this, name, { | ||
__proto__: null, | ||
value: val, | ||
@@ -48,2 +49,3 @@ enumerable: true, | ||
_readableState: { | ||
__proto__: null, | ||
get: makeGetter('_readableState'), | ||
@@ -55,2 +57,3 @@ set: makeSetter('_readableState'), | ||
_writableState: { | ||
__proto__: null, | ||
get: makeGetter('_writableState'), | ||
@@ -57,0 +60,0 @@ set: makeSetter('_writableState'), |
@@ -23,3 +23,3 @@ 'use strict' | ||
PromiseReject, | ||
PromisePrototypeCatch, | ||
PromisePrototypeThen, | ||
Symbol | ||
@@ -131,3 +131,3 @@ } = require('../../ours/primordials') | ||
const val = PromiseReject(err) | ||
PromisePrototypeCatch(val, onDone) | ||
PromisePrototypeThen(val, undefined, onDone) | ||
queue.push(val) | ||
@@ -228,3 +228,2 @@ } finally { | ||
async function some(fn, options = undefined) { | ||
// eslint-disable-next-line no-unused-vars | ||
for await (const unused of filter.call(this, fn, options)) { | ||
@@ -231,0 +230,0 @@ return true |
@@ -0,5 +1,9 @@ | ||
/* replacement start */ | ||
const process = require('process') | ||
/* replacement end */ | ||
// Ported from https://github.com/mafintosh/pump with | ||
// permission from the author, Mathias Buus (@mafintosh). | ||
'use strict' | ||
;('use strict') | ||
const { ArrayIsArray, Promise, SymbolAsyncIterator } = require('../../ours/primordials') | ||
@@ -17,3 +21,9 @@ | ||
aggregateTwoErrors, | ||
codes: { ERR_INVALID_ARG_TYPE, ERR_INVALID_RETURN_VALUE, ERR_MISSING_ARGS, ERR_STREAM_DESTROYED }, | ||
codes: { | ||
ERR_INVALID_ARG_TYPE, | ||
ERR_INVALID_RETURN_VALUE, | ||
ERR_MISSING_ARGS, | ||
ERR_STREAM_DESTROYED, | ||
ERR_STREAM_PREMATURE_CLOSE | ||
}, | ||
AbortError | ||
@@ -358,2 +368,9 @@ } = require('../../ours/errors') | ||
function pipe(src, dst, finish, { end }) { | ||
let ended = false | ||
dst.on('close', () => { | ||
if (!ended) { | ||
// Finish if the destination closes before the source has completed. | ||
finish(new ERR_STREAM_PREMATURE_CLOSE()) | ||
} | ||
}) | ||
src.pipe(dst, { | ||
@@ -367,3 +384,6 @@ end | ||
// Now they allow it but "secretly" don't close the underlying fd. | ||
src.once('end', () => dst.end()) | ||
src.once('end', () => { | ||
ended = true | ||
dst.end() | ||
}) | ||
} else { | ||
@@ -370,0 +390,0 @@ finish() |
@@ -0,1 +1,4 @@ | ||
/* replacement start */ | ||
const process = require('process') | ||
/* replacement end */ | ||
// Copyright Joyent, Inc. and other Node contributors. | ||
@@ -21,4 +24,5 @@ // | ||
// USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
'use strict' | ||
;('use strict') | ||
const { | ||
@@ -45,2 +49,4 @@ ArrayPrototypeIndexOf, | ||
const { Buffer } = require('buffer') | ||
const { addAbortSignal } = require('./add-abort-signal') | ||
@@ -1079,2 +1085,4 @@ | ||
readable: { | ||
__proto__: null, | ||
get() { | ||
@@ -1097,2 +1105,3 @@ const r = this._readableState // r.readable === false means that this is part of a Duplex stream | ||
readableDidRead: { | ||
__proto__: null, | ||
enumerable: false, | ||
@@ -1104,2 +1113,3 @@ get: function () { | ||
readableAborted: { | ||
__proto__: null, | ||
enumerable: false, | ||
@@ -1115,2 +1125,3 @@ get: function () { | ||
readableHighWaterMark: { | ||
__proto__: null, | ||
enumerable: false, | ||
@@ -1122,2 +1133,3 @@ get: function () { | ||
readableBuffer: { | ||
__proto__: null, | ||
enumerable: false, | ||
@@ -1129,2 +1141,3 @@ get: function () { | ||
readableFlowing: { | ||
__proto__: null, | ||
enumerable: false, | ||
@@ -1141,2 +1154,3 @@ get: function () { | ||
readableLength: { | ||
__proto__: null, | ||
enumerable: false, | ||
@@ -1149,2 +1163,3 @@ | ||
readableObjectMode: { | ||
__proto__: null, | ||
enumerable: false, | ||
@@ -1157,2 +1172,3 @@ | ||
readableEncoding: { | ||
__proto__: null, | ||
enumerable: false, | ||
@@ -1165,2 +1181,3 @@ | ||
errored: { | ||
__proto__: null, | ||
enumerable: false, | ||
@@ -1173,2 +1190,4 @@ | ||
closed: { | ||
__proto__: null, | ||
get() { | ||
@@ -1179,2 +1198,3 @@ return this._readableState ? this._readableState.closed : false | ||
destroyed: { | ||
__proto__: null, | ||
enumerable: false, | ||
@@ -1198,2 +1218,3 @@ | ||
readableEnded: { | ||
__proto__: null, | ||
enumerable: false, | ||
@@ -1209,2 +1230,4 @@ | ||
pipesCount: { | ||
__proto__: null, | ||
get() { | ||
@@ -1216,2 +1239,4 @@ return this.pipes.length | ||
paused: { | ||
__proto__: null, | ||
get() { | ||
@@ -1309,4 +1334,4 @@ return this[kPaused] !== false | ||
Readable.toWeb = function (streamReadable) { | ||
return lazyWebStreams().newReadableStreamFromStreamReadable(streamReadable) | ||
Readable.toWeb = function (streamReadable, options) { | ||
return lazyWebStreams().newReadableStreamFromStreamReadable(streamReadable, options) | ||
} | ||
@@ -1313,0 +1338,0 @@ |
@@ -72,2 +72,4 @@ // Copyright Joyent, Inc. and other Node contributors. | ||
const { getHighWaterMark } = require('./state') | ||
ObjectSetPrototypeOf(Transform.prototype, Duplex.prototype) | ||
@@ -78,3 +80,24 @@ ObjectSetPrototypeOf(Transform, Duplex) | ||
function Transform(options) { | ||
if (!(this instanceof Transform)) return new Transform(options) | ||
if (!(this instanceof Transform)) return new Transform(options) // TODO (ronag): This should preferably always be | ||
// applied but would be semver-major. Or even better; | ||
// make Transform a Readable with the Writable interface. | ||
const readableHighWaterMark = options ? getHighWaterMark(this, options, 'readableHighWaterMark', true) : null | ||
if (readableHighWaterMark === 0) { | ||
// A Duplex will buffer both on the writable and readable side while | ||
// a Transform just wants to buffer hwm number of elements. To avoid | ||
// buffering twice we disable buffering on the writable side. | ||
options = { | ||
...options, | ||
highWaterMark: null, | ||
readableHighWaterMark, | ||
// TODO (ronag): 0 is not optimal since we have | ||
// a "bug" where we check needDrain before calling _write and not after. | ||
// Refs: https://github.com/nodejs/node/pull/32887 | ||
// Refs: https://github.com/nodejs/node/pull/35941 | ||
writableHighWaterMark: options.writableHighWaterMark || 0 | ||
} | ||
} | ||
Duplex.call(this, options) // We have implemented the _read method, and done the other things | ||
@@ -160,5 +183,3 @@ // that Readable wants before the first _read call, so unset the | ||
length === rState.length || // Backwards compat. | ||
rState.length < rState.highWaterMark || | ||
rState.highWaterMark === 0 || | ||
rState.length === 0 | ||
rState.length < rState.highWaterMark | ||
) { | ||
@@ -165,0 +186,0 @@ callback() |
@@ -0,1 +1,4 @@ | ||
/* replacement start */ | ||
const process = require('process') | ||
/* replacement end */ | ||
// Copyright Joyent, Inc. and other Node contributors. | ||
@@ -24,4 +27,5 @@ // | ||
// the drain event emission and buffering. | ||
'use strict' | ||
;('use strict') | ||
const { | ||
@@ -46,2 +50,4 @@ ArrayPrototypeSlice, | ||
const { Buffer } = require('buffer') | ||
const destroyImpl = require('./destroy') | ||
@@ -179,2 +185,4 @@ | ||
ObjectDefineProperty(WritableState.prototype, 'bufferedRequestCount', { | ||
__proto__: null, | ||
get() { | ||
@@ -221,2 +229,3 @@ return this.buffered.length - this.bufferedIndex | ||
ObjectDefineProperty(Writable, SymbolHasInstance, { | ||
__proto__: null, | ||
value: function (object) { | ||
@@ -735,2 +744,4 @@ if (FunctionPrototypeSymbolHasInstance(this, object)) return true | ||
closed: { | ||
__proto__: null, | ||
get() { | ||
@@ -741,2 +752,4 @@ return this._writableState ? this._writableState.closed : false | ||
destroyed: { | ||
__proto__: null, | ||
get() { | ||
@@ -754,2 +767,4 @@ return this._writableState ? this._writableState.destroyed : false | ||
writable: { | ||
__proto__: null, | ||
get() { | ||
@@ -772,2 +787,4 @@ const w = this._writableState // w.writable === false means that this is part of a Duplex stream | ||
writableFinished: { | ||
__proto__: null, | ||
get() { | ||
@@ -778,2 +795,4 @@ return this._writableState ? this._writableState.finished : false | ||
writableObjectMode: { | ||
__proto__: null, | ||
get() { | ||
@@ -784,2 +803,4 @@ return this._writableState ? this._writableState.objectMode : false | ||
writableBuffer: { | ||
__proto__: null, | ||
get() { | ||
@@ -790,2 +811,4 @@ return this._writableState && this._writableState.getBuffer() | ||
writableEnded: { | ||
__proto__: null, | ||
get() { | ||
@@ -796,2 +819,4 @@ return this._writableState ? this._writableState.ending : false | ||
writableNeedDrain: { | ||
__proto__: null, | ||
get() { | ||
@@ -804,2 +829,4 @@ const wState = this._writableState | ||
writableHighWaterMark: { | ||
__proto__: null, | ||
get() { | ||
@@ -810,2 +837,4 @@ return this._writableState && this._writableState.highWaterMark | ||
writableCorked: { | ||
__proto__: null, | ||
get() { | ||
@@ -816,2 +845,4 @@ return this._writableState ? this._writableState.corked : 0 | ||
writableLength: { | ||
__proto__: null, | ||
get() { | ||
@@ -822,2 +853,3 @@ return this._writableState && this._writableState.length | ||
errored: { | ||
__proto__: null, | ||
enumerable: false, | ||
@@ -830,2 +862,3 @@ | ||
writableAborted: { | ||
__proto__: null, | ||
enumerable: false, | ||
@@ -832,0 +865,0 @@ get: function () { |
@@ -9,6 +9,8 @@ 'use strict' | ||
NumberIsInteger, | ||
NumberIsNaN, | ||
NumberMAX_SAFE_INTEGER, | ||
NumberMIN_SAFE_INTEGER, | ||
NumberParseInt, | ||
RegExpPrototypeTest, | ||
ObjectPrototypeHasOwnProperty, | ||
RegExpPrototypeExec, | ||
String, | ||
@@ -29,2 +31,6 @@ StringPrototypeToUpperCase, | ||
const signals = {} | ||
/** | ||
* @param {*} value | ||
* @returns {boolean} | ||
*/ | ||
@@ -34,2 +40,6 @@ function isInt32(value) { | ||
} | ||
/** | ||
* @param {*} value | ||
* @returns {boolean} | ||
*/ | ||
@@ -61,3 +71,3 @@ function isUint32(value) { | ||
if (typeof value === 'string') { | ||
if (!RegExpPrototypeTest(octalReg, value)) { | ||
if (RegExpPrototypeExec(octalReg, value) === null) { | ||
throw new ERR_INVALID_ARG_VALUE(name, value, modeDesc) | ||
@@ -69,6 +79,16 @@ } | ||
validateInt32(value, name, 0, 2 ** 32 - 1) | ||
validateUint32(value, name) | ||
return value | ||
} | ||
/** | ||
* @callback validateInteger | ||
* @param {*} value | ||
* @param {string} name | ||
* @param {number} [min] | ||
* @param {number} [max] | ||
* @returns {asserts value is number} | ||
*/ | ||
/** @type {validateInteger} */ | ||
const validateInteger = hideStackFrames((value, name, min = NumberMIN_SAFE_INTEGER, max = NumberMAX_SAFE_INTEGER) => { | ||
@@ -79,2 +99,13 @@ if (typeof value !== 'number') throw new ERR_INVALID_ARG_TYPE(name, 'number', value) | ||
}) | ||
/** | ||
* @callback validateInt32 | ||
* @param {*} value | ||
* @param {string} name | ||
* @param {number} [min] | ||
* @param {number} [max] | ||
* @returns {asserts value is number} | ||
*/ | ||
/** @type {validateInt32} */ | ||
const validateInt32 = hideStackFrames((value, name, min = -2147483648, max = 2147483647) => { | ||
@@ -86,8 +117,4 @@ // The defaults for min and max correspond to the limits of 32-bit integers. | ||
if (!isInt32(value)) { | ||
if (!NumberIsInteger(value)) { | ||
throw new ERR_OUT_OF_RANGE(name, 'an integer', value) | ||
} | ||
throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value) | ||
if (!NumberIsInteger(value)) { | ||
throw new ERR_OUT_OF_RANGE(name, 'an integer', value) | ||
} | ||
@@ -99,3 +126,13 @@ | ||
}) | ||
const validateUint32 = hideStackFrames((value, name, positive) => { | ||
/** | ||
* @callback validateUint32 | ||
* @param {*} value | ||
* @param {string} name | ||
* @param {number|boolean} [positive=false] | ||
* @returns {asserts value is number} | ||
*/ | ||
/** @type {validateUint32} */ | ||
const validateUint32 = hideStackFrames((value, name, positive = false) => { | ||
if (typeof value !== 'number') { | ||
@@ -105,25 +142,62 @@ throw new ERR_INVALID_ARG_TYPE(name, 'number', value) | ||
if (!isUint32(value)) { | ||
if (!NumberIsInteger(value)) { | ||
throw new ERR_OUT_OF_RANGE(name, 'an integer', value) | ||
} | ||
if (!NumberIsInteger(value)) { | ||
throw new ERR_OUT_OF_RANGE(name, 'an integer', value) | ||
} | ||
const min = positive ? 1 : 0 // 2 ** 32 === 4294967296 | ||
const min = positive ? 1 : 0 // 2 ** 32 === 4294967296 | ||
throw new ERR_OUT_OF_RANGE(name, `>= ${min} && < 4294967296`, value) | ||
} | ||
const max = 4_294_967_295 | ||
if (positive && value === 0) { | ||
throw new ERR_OUT_OF_RANGE(name, '>= 1 && < 4294967296', value) | ||
if (value < min || value > max) { | ||
throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value) | ||
} | ||
}) | ||
/** | ||
* @callback validateString | ||
* @param {*} value | ||
* @param {string} name | ||
* @returns {asserts value is string} | ||
*/ | ||
/** @type {validateString} */ | ||
function validateString(value, name) { | ||
if (typeof value !== 'string') throw new ERR_INVALID_ARG_TYPE(name, 'string', value) | ||
} | ||
/** | ||
* @callback validateNumber | ||
* @param {*} value | ||
* @param {string} name | ||
* @param {number} [min] | ||
* @param {number} [max] | ||
* @returns {asserts value is number} | ||
*/ | ||
function validateNumber(value, name) { | ||
/** @type {validateNumber} */ | ||
function validateNumber(value, name, min = undefined, max) { | ||
if (typeof value !== 'number') throw new ERR_INVALID_ARG_TYPE(name, 'number', value) | ||
if ( | ||
(min != null && value < min) || | ||
(max != null && value > max) || | ||
((min != null || max != null) && NumberIsNaN(value)) | ||
) { | ||
throw new ERR_OUT_OF_RANGE( | ||
name, | ||
`${min != null ? `>= ${min}` : ''}${min != null && max != null ? ' && ' : ''}${max != null ? `<= ${max}` : ''}`, | ||
value | ||
) | ||
} | ||
} | ||
/** | ||
* @callback validateOneOf | ||
* @template T | ||
* @param {T} value | ||
* @param {string} name | ||
* @param {T[]} oneOf | ||
*/ | ||
/** @type {validateOneOf} */ | ||
const validateOneOf = hideStackFrames((value, name, oneOf) => { | ||
@@ -139,8 +213,21 @@ if (!ArrayPrototypeIncludes(oneOf, value)) { | ||
}) | ||
/** | ||
* @callback validateBoolean | ||
* @param {*} value | ||
* @param {string} name | ||
* @returns {asserts value is boolean} | ||
*/ | ||
/** @type {validateBoolean} */ | ||
function validateBoolean(value, name) { | ||
if (typeof value !== 'boolean') throw new ERR_INVALID_ARG_TYPE(name, 'boolean', value) | ||
} | ||
function getOwnPropertyValueOrDefault(options, key, defaultValue) { | ||
return options == null || !ObjectPrototypeHasOwnProperty(options, key) ? defaultValue : options[key] | ||
} | ||
/** | ||
* @param {unknown} value | ||
* @callback validateObject | ||
* @param {*} value | ||
* @param {string} name | ||
@@ -154,8 +241,9 @@ * @param {{ | ||
const validateObject = hideStackFrames((value, name, options) => { | ||
const useDefaultOptions = options == null | ||
const allowArray = useDefaultOptions ? false : options.allowArray | ||
const allowFunction = useDefaultOptions ? false : options.allowFunction | ||
const nullable = useDefaultOptions ? false : options.nullable | ||
/** @type {validateObject} */ | ||
const validateObject = hideStackFrames((value, name, options = null) => { | ||
const allowArray = getOwnPropertyValueOrDefault(options, 'allowArray', false) | ||
const allowFunction = getOwnPropertyValueOrDefault(options, 'allowFunction', false) | ||
const nullable = getOwnPropertyValueOrDefault(options, 'nullable', false) | ||
if ( | ||
@@ -169,2 +257,12 @@ (!nullable && value === null) || | ||
}) | ||
/** | ||
* @callback validateArray | ||
* @param {*} value | ||
* @param {string} name | ||
* @param {number} [minLength] | ||
* @returns {asserts value is any[]} | ||
*/ | ||
/** @type {validateArray} */ | ||
const validateArray = hideStackFrames((value, name, minLength = 0) => { | ||
@@ -179,4 +277,10 @@ if (!ArrayIsArray(value)) { | ||
} | ||
}) | ||
}) // eslint-disable-next-line jsdoc/require-returns-check | ||
/** | ||
* @param {*} signal | ||
* @param {string} [name='signal'] | ||
* @returns {asserts signal is keyof signals} | ||
*/ | ||
function validateSignalName(signal, name = 'signal') { | ||
@@ -193,3 +297,11 @@ validateString(signal, name) | ||
} | ||
/** | ||
* @callback validateBuffer | ||
* @param {*} buffer | ||
* @param {string} [name='buffer'] | ||
* @returns {asserts buffer is ArrayBufferView} | ||
*/ | ||
/** @type {validateBuffer} */ | ||
const validateBuffer = hideStackFrames((buffer, name = 'buffer') => { | ||
@@ -200,2 +312,6 @@ if (!isArrayBufferView(buffer)) { | ||
}) | ||
/** | ||
* @param {string} data | ||
* @param {string} encoding | ||
*/ | ||
@@ -209,4 +325,11 @@ function validateEncoding(data, encoding) { | ||
} | ||
} // Check that the port number is not NaN when coerced to a number, | ||
// is an integer and that it falls within the legal range of port numbers. | ||
} | ||
/** | ||
* Check that the port number is not NaN when coerced to a number, | ||
* is an integer and that it falls within the legal range of port numbers. | ||
* @param {*} port | ||
* @param {string} [name='Port'] | ||
* @param {boolean} [allowZero=true] | ||
* @returns {number} | ||
*/ | ||
@@ -226,3 +349,10 @@ function validatePort(port, name = 'Port', allowZero = true) { | ||
} | ||
/** | ||
* @callback validateAbortSignal | ||
* @param {*} signal | ||
* @param {string} name | ||
*/ | ||
/** @type {validateAbortSignal} */ | ||
const validateAbortSignal = hideStackFrames((signal, name) => { | ||
@@ -233,11 +363,51 @@ if (signal !== undefined && (signal === null || typeof signal !== 'object' || !('aborted' in signal))) { | ||
}) | ||
/** | ||
* @callback validateFunction | ||
* @param {*} value | ||
* @param {string} name | ||
* @returns {asserts value is Function} | ||
*/ | ||
/** @type {validateFunction} */ | ||
const validateFunction = hideStackFrames((value, name) => { | ||
if (typeof value !== 'function') throw new ERR_INVALID_ARG_TYPE(name, 'Function', value) | ||
}) | ||
/** | ||
* @callback validatePlainFunction | ||
* @param {*} value | ||
* @param {string} name | ||
* @returns {asserts value is Function} | ||
*/ | ||
/** @type {validatePlainFunction} */ | ||
const validatePlainFunction = hideStackFrames((value, name) => { | ||
if (typeof value !== 'function' || isAsyncFunction(value)) throw new ERR_INVALID_ARG_TYPE(name, 'Function', value) | ||
}) | ||
/** | ||
* @callback validateUndefined | ||
* @param {*} value | ||
* @param {string} name | ||
* @returns {asserts value is undefined} | ||
*/ | ||
/** @type {validateUndefined} */ | ||
const validateUndefined = hideStackFrames((value, name) => { | ||
if (value !== undefined) throw new ERR_INVALID_ARG_TYPE(name, 'undefined', value) | ||
}) | ||
/** | ||
* @template T | ||
* @param {T} value | ||
* @param {string} name | ||
* @param {T[]} union | ||
*/ | ||
function validateUnion(value, name, union) { | ||
if (!ArrayPrototypeIncludes(union, value)) { | ||
throw new ERR_INVALID_ARG_TYPE(name, `('${ArrayPrototypeJoin(union, '|')}')`, value) | ||
} | ||
} | ||
module.exports = { | ||
@@ -263,3 +433,4 @@ isInt32, | ||
validateUndefined, | ||
validateUnion, | ||
validateAbortSignal | ||
} |
@@ -41,2 +41,3 @@ 'use strict' | ||
AggregateError, | ||
kEmptyObject: Object.freeze({}), | ||
@@ -43,0 +44,0 @@ once(callback) { |
@@ -0,1 +1,4 @@ | ||
/* replacement start */ | ||
const { Buffer } = require('buffer') | ||
/* replacement end */ | ||
// Copyright Joyent, Inc. and other Node contributors. | ||
@@ -21,4 +24,5 @@ // | ||
// USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
'use strict' | ||
;('use strict') | ||
const { ObjectDefineProperty, ObjectKeys, ReflectApply } = require('./ours/primordials') | ||
@@ -69,8 +73,11 @@ | ||
ObjectDefineProperty(fn, 'name', { | ||
__proto__: null, | ||
value: op.name | ||
}) | ||
ObjectDefineProperty(fn, 'length', { | ||
__proto__: null, | ||
value: op.length | ||
}) | ||
ObjectDefineProperty(Stream.Readable.prototype, key, { | ||
__proto__: null, | ||
value: fn, | ||
@@ -95,8 +102,11 @@ enumerable: false, | ||
ObjectDefineProperty(fn, 'name', { | ||
__proto__: null, | ||
value: op.name | ||
}) | ||
ObjectDefineProperty(fn, 'length', { | ||
__proto__: null, | ||
value: op.length | ||
}) | ||
ObjectDefineProperty(Stream.Readable.prototype, key, { | ||
__proto__: null, | ||
value: fn, | ||
@@ -122,2 +132,3 @@ enumerable: false, | ||
ObjectDefineProperty(Stream, 'promises', { | ||
__proto__: null, | ||
configurable: true, | ||
@@ -131,2 +142,3 @@ enumerable: true, | ||
ObjectDefineProperty(pipeline, customPromisify, { | ||
__proto__: null, | ||
enumerable: true, | ||
@@ -139,2 +151,3 @@ | ||
ObjectDefineProperty(eos, customPromisify, { | ||
__proto__: null, | ||
enumerable: true, | ||
@@ -141,0 +154,0 @@ |
{ | ||
"name": "readable-stream", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"description": "Node.js Streams, a user-land copy of the stream library from Node.js", | ||
@@ -47,3 +47,6 @@ "homepage": "https://github.com/nodejs/readable-stream", | ||
"dependencies": { | ||
"abort-controller": "^3.0.0" | ||
"abort-controller": "^3.0.0", | ||
"buffer": "^6.0.3", | ||
"events": "^3.3.0", | ||
"process": "^0.11.10" | ||
}, | ||
@@ -59,3 +62,2 @@ "devDependencies": { | ||
"browserify": "^17.0.0", | ||
"buffer-es6": "^4.9.3", | ||
"c8": "^7.11.2", | ||
@@ -71,3 +73,2 @@ "esbuild": "^0.14.39", | ||
"prettier": "^2.6.2", | ||
"process-es6": "^0.11.6", | ||
"rollup": "^2.72.1", | ||
@@ -74,0 +75,0 @@ "rollup-plugin-polyfill-node": "^0.9.0", |
@@ -14,5 +14,5 @@ # readable-stream | ||
This package is a mirror of the streams implementations in Node.js 18.0.0. | ||
This package is a mirror of the streams implementations in Node.js 18.9.0. | ||
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v18.0.0/docs/api/stream.html). | ||
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v18.9.0/docs/api/stream.html). | ||
@@ -19,0 +19,0 @@ If you want to guarantee a stable streams base, regardless of what version of |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
199986
27
5848
1
4
+ Addedbuffer@^6.0.3
+ Addedevents@^3.3.0
+ Addedprocess@^0.11.10
+ Addedbase64-js@1.5.1(transitive)
+ Addedbuffer@6.0.3(transitive)
+ Addedevents@3.3.0(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedprocess@0.11.10(transitive)