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.0.0 to 3.0.1

84

errors-browser.js
'use strict';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

@@ -16,7 +18,7 @@

function getMessage(arg1, arg2) {
function getMessage(arg1, arg2, arg3) {
if (typeof message === 'string') {
return message;
} else {
return message(arg1, arg2);
return message(arg1, arg2, arg3);
}

@@ -28,6 +30,6 @@ }

function NodeError(arg1, arg2) {
function NodeError(arg1, arg2, arg3) {
_classCallCheck(this, NodeError);
return _possibleConstructorReturn(this, (NodeError.__proto__ || Object.getPrototypeOf(NodeError)).call(this, getMessage(arg1, arg2)));
return _possibleConstructorReturn(this, (NodeError.__proto__ || Object.getPrototypeOf(NodeError)).call(this, getMessage(arg1, arg2, arg3)));
}

@@ -44,6 +46,72 @@

// https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
function oneOf(expected, thing) {
if (Array.isArray(expected)) {
var len = expected.length;
expected = expected.map(function (i) {
return String(i);
});
if (len > 2) {
return 'one of ' + thing + ' ' + expected.slice(0, len - 1).join(', ') + ', or ' + expected[len - 1];
} else if (len === 2) {
return 'one of ' + thing + ' ' + expected[0] + ' or ' + expected[1];
} else {
return 'of ' + thing + ' ' + expected[0];
}
} else {
return 'of ' + thing + ' ' + String(expected);
}
}
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
function startsWith(str, search, pos) {
return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
}
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
function endsWith(str, search, this_len) {
if (this_len === undefined || this_len > str.length) {
this_len = str.length;
}
return str.substring(this_len - search.length, this_len) === search;
}
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
function includes(str, search, start) {
if (typeof start !== 'number') {
start = 0;
}
if (start + search.length > str.length) {
return false;
} else {
return str.indexOf(search, start) !== -1;
}
}
createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {
return 'The value "' + value + '" is invalid for option "' + name + '"';
}, TypeError);
createErrorType('ERR_INVALID_ARG_TYPE', 'argument must be of the right type', TypeError);
createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {
// determiner: 'must be' or 'must not be'
var determiner = void 0;
if (typeof expected === 'string' && startsWith(expected, 'not ')) {
determiner = 'must not be';
expected = expected.replace(/^not /, '');
} else {
determiner = 'must be';
}
var msg = void 0;
if (endsWith(name, ' argument')) {
// For cases like 'first argument'
msg = 'The ' + name + ' ' + determiner + ' ' + oneOf(expected, 'type');
} else {
var type = includes(name, '.') ? 'property' : 'argument';
msg = 'The "' + name + '" ' + type + ' ' + determiner + ' ' + oneOf(expected, 'type');
}
msg += '. Received type ' + (typeof actual === 'undefined' ? 'undefined' : _typeof(actual));
return msg;
}, TypeError);
createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');

@@ -53,4 +121,6 @@ createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {

});
createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'premature close');
createErrorType('ERR_STREAM_DESTROYED', 'the stream was destroyed');
createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close');
createErrorType('ERR_STREAM_DESTROYED', function (name) {
return 'Cannot call ' + name + ' after a stream was destroyed';
});
createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');

@@ -57,0 +127,0 @@ createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');

@@ -10,7 +10,7 @@ 'use strict';

function getMessage (arg1, arg2) {
function getMessage (arg1, arg2, arg3) {
if (typeof message === 'string') {
return message
} else {
return message(arg1, arg2)
return message(arg1, arg2, arg3)
}

@@ -20,4 +20,4 @@ }

class NodeError extends Base {
constructor (arg1, arg2) {
super(getMessage(arg1, arg2));
constructor (arg1, arg2, arg3) {
super(getMessage(arg1, arg2, arg3));
}

@@ -32,6 +32,71 @@ }

// https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
function oneOf(expected, thing) {
if (Array.isArray(expected)) {
const len = expected.length;
expected = expected.map((i) => String(i));
if (len > 2) {
return `one of ${thing} ${expected.slice(0, len - 1).join(', ')}, or ` +
expected[len - 1];
} else if (len === 2) {
return `one of ${thing} ${expected[0]} or ${expected[1]}`;
} else {
return `of ${thing} ${expected[0]}`;
}
} else {
return `of ${thing} ${String(expected)}`;
}
}
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
function startsWith(str, search, pos) {
return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
}
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
function endsWith(str, search, this_len) {
if (this_len === undefined || this_len > str.length) {
this_len = str.length;
}
return str.substring(this_len - search.length, this_len) === search;
}
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
function includes(str, search, start) {
if (typeof start !== 'number') {
start = 0;
}
if (start + search.length > str.length) {
return false;
} else {
return str.indexOf(search, start) !== -1;
}
}
createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {
return 'The value "' + value + '" is invalid for option "' + name + '"'
}, TypeError);
createErrorType('ERR_INVALID_ARG_TYPE', 'argument must be of the right type', TypeError);
createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {
// determiner: 'must be' or 'must not be'
let determiner;
if (typeof expected === 'string' && startsWith(expected, 'not ')) {
determiner = 'must not be';
expected = expected.replace(/^not /, '');
} else {
determiner = 'must be';
}
let msg;
if (endsWith(name, ' argument')) {
// For cases like 'first argument'
msg = `The ${name} ${determiner} ${oneOf(expected, 'type')}`;
} else {
const type = includes(name, '.') ? 'property' : 'argument';
msg = `The "${name}" ${type} ${determiner} ${oneOf(expected, 'type')}`;
}
msg += `. Received type ${typeof actual}`;
return msg;
}, TypeError);
createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');

@@ -41,4 +106,6 @@ createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {

});
createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'premature close');
createErrorType('ERR_STREAM_DESTROYED', 'the stream was destroyed');
createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'Premature close');
createErrorType('ERR_STREAM_DESTROYED', function (name) {
return 'Cannot call ' + name + ' after a stream was destroyed';
});
createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');

@@ -45,0 +112,0 @@ createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');

6

lib/_stream_duplex.js

@@ -31,6 +31,2 @@ // Copyright Joyent, Inc. and other Node contributors.

var pna = require('process-nextick-args');
/*</replacement>*/
/*<replacement>*/
var objectKeys = Object.keys || function (obj) {

@@ -116,3 +112,3 @@ var keys = [];

// But allow more writes to happen in this tick.
pna.nextTick(onEndNT, this);
process.nextTick(onEndNT, this);
}

@@ -119,0 +115,0 @@

@@ -24,7 +24,2 @@ // Copyright Joyent, Inc. and other Node contributors.

/*<replacement>*/
var pna = require('process-nextick-args');
/*</replacement>*/
module.exports = Readable;

@@ -515,3 +510,3 @@

state.emittedReadable = true;
pna.nextTick(emitReadable_, stream);
process.nextTick(emitReadable_, stream);
}

@@ -546,3 +541,3 @@ }

state.readingMore = true;
pna.nextTick(maybeReadMore_, stream, state);
process.nextTick(maybeReadMore_, stream, state);
}

@@ -592,3 +587,3 @@ }

var endFn = doEnd ? onend : unpipe;
if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
if (state.endEmitted) process.nextTick(endFn);else src.once('end', endFn);

@@ -783,3 +778,3 @@ dest.on('unpipe', onunpipe);

} else if (!state.reading) {
pna.nextTick(nReadingNextTick, this);
process.nextTick(nReadingNextTick, this);
}

@@ -803,3 +798,3 @@ }

// effect.
pna.nextTick(updateReadableListening, this);
process.nextTick(updateReadableListening, this);
}

@@ -820,3 +815,3 @@

// effect.
pna.nextTick(updateReadableListening, this);
process.nextTick(updateReadableListening, this);
}

@@ -853,3 +848,3 @@

state.resumeScheduled = true;
pna.nextTick(resume_, stream, state);
process.nextTick(resume_, stream, state);
}

@@ -1030,3 +1025,3 @@ }

state.ended = true;
pna.nextTick(endReadableNT, state, stream);
process.nextTick(endReadableNT, state, stream);
}

@@ -1033,0 +1028,0 @@ }

@@ -28,7 +28,2 @@ // Copyright Joyent, Inc. and other Node contributors.

/*<replacement>*/
var pna = require('process-nextick-args');
/*</replacement>*/
module.exports = Writable;

@@ -58,6 +53,2 @@

/*<replacement>*/
var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
/*</replacement>*/
/*<replacement>*/
var Duplex;

@@ -296,3 +287,3 @@ /*</replacement>*/

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

@@ -313,3 +304,3 @@

stream.emit('error', er);
pna.nextTick(cb, er);
process.nextTick(cb, er);
return false;

@@ -452,6 +443,6 @@ }

// to avoid piling up things on the stack
pna.nextTick(cb, er);
process.nextTick(cb, er);
// this can emit finish, and it will always happen
// after error
pna.nextTick(finishMaybe, stream, state);
process.nextTick(finishMaybe, stream, state);
stream._writableState.errorEmitted = true;

@@ -496,5 +487,3 @@ stream.emit('error', er);

if (sync) {
/*<replacement>*/
asyncWrite(afterWrite, stream, state, finished, cb);
/*</replacement>*/
process.nextTick(afterWrite, stream, state, finished, cb);
} else {

@@ -646,3 +635,3 @@ afterWrite(stream, state, finished, cb);

state.finalCalled = true;
pna.nextTick(callFinal, stream, state);
process.nextTick(callFinal, stream, state);
} else {

@@ -671,3 +660,3 @@ state.prefinished = true;

if (cb) {
if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
if (state.finished) process.nextTick(cb);else stream.once('finish', cb);
}

@@ -674,0 +663,0 @@ state.ended = true;

'use strict';
/*<replacement>*/
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

@@ -9,5 +7,2 @@

var pna = require('process-nextick-args');
/*</replacement>*/
var kLastResolve = Symbol('lastResolve');

@@ -47,3 +42,3 @@ var kLastReject = Symbol('lastReject');

// emit an error with process.nextTick
pna.nextTick(readAndResolve, iter);
process.nextTick(readAndResolve, iter);
}

@@ -50,0 +45,0 @@

'use strict';
/*<replacement>*/
// undocumented cb() API, needed for core, not for public API
var pna = require('process-nextick-args');
/*</replacement>*/
// undocumented cb() API, needed for core, not for public API
function destroy(err, cb) {

@@ -19,3 +15,3 @@ var _this = this;

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

@@ -39,3 +35,3 @@ return this;

if (!cb && err) {
pna.nextTick(emitErrorAndCloseNT, _this, err);
process.nextTick(emitErrorAndCloseNT, _this, err);
if (_this._writableState) {

@@ -45,6 +41,6 @@ _this._writableState.errorEmitted = true;

} else if (cb) {
pna.nextTick(emitCloseNT, _this);
process.nextTick(emitCloseNT, _this);
cb(err);
} else {
pna.nextTick(emitCloseNT, _this);
process.nextTick(emitCloseNT, _this);
}

@@ -51,0 +47,0 @@ });

@@ -6,7 +6,2 @@ // Ported from https://github.com/mafintosh/end-of-stream with

/*<replacement>*/
var pna = require('process-nextick-args');
/*</replacement>*/
var ERR_STREAM_PREMATURE_CLOSE = require('../../../errors').codes.ERR_STREAM_PREMATURE_CLOSE;

@@ -13,0 +8,0 @@

@@ -6,7 +6,2 @@ // Ported from https://github.com/mafintosh/pump with

/*<replacement>*/
var pna = require('process-nextick-args');
/*</replacement>*/
var eos = void 0;

@@ -13,0 +8,0 @@

'use strict';
/*<replacement>*/
var pna = require('process-nextick-args');
/*</replacement>*/
var ERR_INVALID_OPT_VALUE = require('../../../errors').codes.ERR_INVALID_OPT_VALUE;

@@ -9,0 +4,0 @@

{
"name": "readable-stream",
"version": "3.0.0",
"version": "3.0.1",
"description": "Streams3, a user-land copy of the stream library from Node.js",

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

"inherits": "^2.0.3",
"process-nextick-args": "^2.0.0",
"string_decoder": "^1.1.1",

@@ -11,0 +10,0 @@ "util-deprecate": "^1.0.1"

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