Socket
Socket
Sign inDemoInstall

readable-stream

Package Overview
Dependencies
4
Maintainers
6
Versions
103
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.4.0 to 3.5.0

lib/internal/streams/from-browser.js

71

lib/_stream_readable.js

@@ -83,13 +83,12 @@ // Copyright Joyent, Inc. and other Node contributors.

ERR_METHOD_NOT_IMPLEMENTED = _require$codes.ERR_METHOD_NOT_IMPLEMENTED,
ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;
ERR_STREAM_UNSHIFT_AFTER_END_EVENT = _require$codes.ERR_STREAM_UNSHIFT_AFTER_END_EVENT; // Lazy loaded to improve the startup performance.
var _require2 = require('../experimentalWarning'),
emitExperimentalWarning = _require2.emitExperimentalWarning; // Lazy loaded to improve the startup performance.
var StringDecoder;
var createReadableStreamAsyncIterator;
var from;
require('inherits')(Readable, Stream);
var errorOrDestroy = destroyImpl.errorOrDestroy;
var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];

@@ -148,4 +147,6 @@

this.emitClose = options.emitClose !== false; // has it been destroyed
this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'end' (and potentially 'finish')
this.autoDestroy = !!options.autoDestroy; // has it been destroyed
this.destroyed = false; // Crypto is kind of old and crusty. Historically, its default string

@@ -262,3 +263,3 @@ // encoding is 'binary' so we have to make this configurable.

if (er) {
stream.emit('error', er);
errorOrDestroy(stream, er);
} else if (state.objectMode || chunk && chunk.length > 0) {

@@ -270,5 +271,5 @@ if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {

if (addToFront) {
if (state.endEmitted) stream.emit('error', new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true);
if (state.endEmitted) errorOrDestroy(stream, new ERR_STREAM_UNSHIFT_AFTER_END_EVENT());else addChunk(stream, state, chunk, true);
} else if (state.ended) {
stream.emit('error', new ERR_STREAM_PUSH_AFTER_EOF());
errorOrDestroy(stream, new ERR_STREAM_PUSH_AFTER_EOF());
} else if (state.destroyed) {

@@ -329,13 +330,28 @@ return false;

if (!StringDecoder) StringDecoder = require('string_decoder/').StringDecoder;
this._readableState.decoder = new StringDecoder(enc); // if setEncoding(null), decoder.encoding equals utf8
var decoder = new StringDecoder(enc);
this._readableState.decoder = decoder; // If setEncoding(null), decoder.encoding equals utf8
this._readableState.encoding = this._readableState.decoder.encoding;
this._readableState.encoding = this._readableState.decoder.encoding; // Iterate over current buffer to convert already stored Buffers:
var p = this._readableState.buffer.head;
var content = '';
while (p !== null) {
content += decoder.write(p.data);
p = p.next;
}
this._readableState.buffer.clear();
if (content !== '') this._readableState.buffer.push(content);
this._readableState.length = content.length;
return this;
}; // Don't raise the hwm > 8MB
}; // Don't raise the hwm > 1GB
var MAX_HWM = 0x800000;
var MAX_HWM = 0x40000000;
function computeNewHighWaterMark(n) {
if (n >= MAX_HWM) {
// TODO(ronag): Throw ERR_VALUE_OUT_OF_RANGE.
n = MAX_HWM;

@@ -457,3 +473,3 @@ } else {

if (ret === null) {
state.needReadable = true;
state.needReadable = state.length <= state.highWaterMark;
n = 0;

@@ -478,2 +494,3 @@ } else {

function onEofChunk(stream, state) {
debug('onEofChunk');
if (state.ended) return;

@@ -513,2 +530,3 @@

var state = stream._readableState;
debug('emitReadable', state.needReadable, state.emittedReadable);
state.needReadable = false;

@@ -529,2 +547,3 @@

stream.emit('readable');
state.emittedReadable = false;
} // The stream needs another readable event if

@@ -595,3 +614,3 @@ // 1. It is not flowing, as the flow mechanism will take

Readable.prototype._read = function (n) {
this.emit('error', new ERR_METHOD_NOT_IMPLEMENTED('_read()'));
errorOrDestroy(this, new ERR_METHOD_NOT_IMPLEMENTED('_read()'));
};

@@ -695,3 +714,3 @@

dest.removeListener('error', onerror);
if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
if (EElistenerCount(dest, 'error') === 0) errorOrDestroy(dest, er);
} // Make sure our error handler is attached before userland ones.

@@ -1000,4 +1019,2 @@

Readable.prototype[Symbol.asyncIterator] = function () {
emitExperimentalWarning('Readable[Symbol.asyncIterator]');
if (createReadableStreamAsyncIterator === undefined) {

@@ -1090,5 +1107,25 @@ createReadableStreamAsyncIterator = require('./internal/streams/async_iterator');

stream.emit('end');
if (state.autoDestroy) {
// In case of duplex streams we need a way to detect
// if the writable side is ready for autoDestroy as well
var wState = stream._writableState;
if (!wState || wState.autoDestroy && wState.finished) {
stream.destroy();
}
}
}
}
if (typeof Symbol === 'function') {
Readable.from = function (iterable, opts) {
if (from === undefined) {
from = require('./internal/streams/from');
}
return from(Readable, iterable, opts);
};
}
function indexOf(xs, x) {

@@ -1095,0 +1132,0 @@ for (var i = 0, l = xs.length; i < l; i++) {

@@ -97,2 +97,4 @@ // Copyright Joyent, Inc. and other Node contributors.

var errorOrDestroy = destroyImpl.errorOrDestroy;
require('inherits')(Writable, Stream);

@@ -177,4 +179,6 @@

this.emitClose = options.emitClose !== false; // count buffered requests
this.emitClose = options.emitClose !== false; // Should .destroy() be called after 'finish' (and potentially 'end')
this.autoDestroy = !!options.autoDestroy; // count buffered requests
this.bufferedRequestCount = 0; // allocate the first CorkedRequest, there is always

@@ -255,3 +259,3 @@ // one allocated and free to use, and we maintain at most two

Writable.prototype.pipe = function () {
this.emit('error', new ERR_STREAM_CANNOT_PIPE());
errorOrDestroy(this, new ERR_STREAM_CANNOT_PIPE());
};

@@ -262,3 +266,3 @@

stream.emit('error', er);
errorOrDestroy(stream, er);
process.nextTick(cb, er);

@@ -280,3 +284,3 @@ } // Checks that a user-supplied chunk is valid, especially for the particular

if (er) {
stream.emit('error', er);
errorOrDestroy(stream, er);
process.nextTick(cb, er);

@@ -425,3 +429,3 @@ return false;

stream._writableState.errorEmitted = true;
stream.emit('error', er);
errorOrDestroy(stream, er);
} else {

@@ -432,3 +436,3 @@ // the caller expect this to happen before if

stream._writableState.errorEmitted = true;
stream.emit('error', er); // this can emit finish, but finish must
errorOrDestroy(stream, er); // this can emit finish, but finish must
// always follow error

@@ -597,3 +601,3 @@

if (err) {
stream.emit('error', err);
errorOrDestroy(stream, err);
}

@@ -629,2 +633,12 @@

stream.emit('finish');
if (state.autoDestroy) {
// In case of duplex streams we need a way to detect
// if the readable side is ready for autoDestroy as well
var rState = stream._readableState;
if (!rState || rState.autoDestroy && rState.endEmitted) {
stream.destroy();
}
}
}

@@ -631,0 +645,0 @@ }

'use strict';
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

@@ -6,0 +8,0 @@

@@ -12,4 +12,9 @@ 'use strict'; // undocumented cb() API, needed for core, not for public API

cb(err);
} else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
process.nextTick(emitErrorNT, this, err);
} else if (err) {
if (!this._writableState) {
process.nextTick(emitErrorNT, this, err);
} else if (!this._writableState.errorEmitted) {
this._writableState.errorEmitted = true;
process.nextTick(emitErrorNT, this, err);
}
}

@@ -33,6 +38,9 @@

if (!cb && err) {
process.nextTick(emitErrorAndCloseNT, _this, err);
if (_this._writableState) {
if (!_this._writableState) {
process.nextTick(emitErrorAndCloseNT, _this, err);
} else if (!_this._writableState.errorEmitted) {
_this._writableState.errorEmitted = true;
process.nextTick(emitErrorAndCloseNT, _this, err);
} else {
process.nextTick(emitCloseNT, _this);
}

@@ -84,5 +92,17 @@ } else if (cb) {

function errorOrDestroy(stream, err) {
// We have tests that rely on errors being emitted
// in the same tick, so changing this is semver major.
// For now when you opt-in to autoDestroy we allow
// the error to be emitted nextTick. In a future
// semver major update we should change the default to this.
var rState = stream._readableState;
var wState = stream._writableState;
if (rState && rState.autoDestroy || wState && wState.autoDestroy) stream.destroy(err);else stream.emit('error', err);
}
module.exports = {
destroy: destroy,
undestroy: undestroy
undestroy: undestroy,
errorOrDestroy: errorOrDestroy
};
{
"name": "readable-stream",
"version": "3.4.0",
"version": "3.5.0",
"description": "Streams3, a user-land copy of the stream library from Node.js",

@@ -23,2 +23,3 @@ "main": "readable.js",

"deep-strict-equal": "^0.2.0",
"events.once": "^2.0.2",
"glob": "^7.1.2",

@@ -59,2 +60,3 @@ "gunzip-maybe": "^1.4.1",

"./readable.js": "./readable-browser.js",
"./lib/internal/streams/from.js": "./lib/internal/streams/from-browser.js",
"./lib/internal/streams/stream.js": "./lib/internal/streams/stream-browser.js"

@@ -61,0 +63,0 @@ },

@@ -18,3 +18,3 @@ # readable-stream

Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v10.15.3/docs/api/stream.html).
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v10.18.1/docs/api/stream.html).

@@ -28,6 +28,3 @@ If you want to guarantee a stable streams base, regardless of what version of

v3.x.x of `readable-stream` supports Node 6, 8, and 10, as well as
evergreen browsers, IE 11 and latest Safari. The breaking changes
introduced by v3 are composed by the combined breaking changes in [Node v9](https://nodejs.org/en/blog/release/v9.0.0/)
and [Node v10](https://nodejs.org/en/blog/release/v10.0.0/), as follows:
v3.x.x of `readable-stream` is a cut from Node 10. This version supports Node 6, 8, and 10, as well as evergreen browsers, IE 11 and latest Safari. The breaking changes introduced by v3 are composed by the combined breaking changes in [Node v9](https://nodejs.org/en/blog/release/v9.0.0/) and [Node v10](https://nodejs.org/en/blog/release/v10.0.0/), as follows:

@@ -56,6 +53,4 @@ 1. Error codes: https://github.com/nodejs/node/pull/13310,

## Version 2.x.x
v2.x.x of `readable-stream` is a cut of the stream module from Node 8 (there have been no semver-major changes from Node 4 to 8). This version supports all Node.js versions from 0.8, as well as evergreen browsers and IE 10 & 11.
v2.x.x of `readable-stream` supports all Node.js version from 0.8, as well as
evergreen browsers and IE 10 & 11.
### Big Thanks

@@ -62,0 +57,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc