Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to @babel/core@7, node 10.14.2 #393

Merged
merged 4 commits into from
Dec 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ npm install --save readable-stream

This package is a mirror of the streams implementations in Node.js.

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

If you want to guarantee a stable streams base, regardless of what version of
Node you, or the users of your libraries are using, use **readable-stream** *only* and avoid the *"stream"* module in Node-core, for background see [this blogpost](http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html).
Expand Down
32 changes: 17 additions & 15 deletions build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const hyperquest = require('hyperquest')
, path = require('path')
, tar = require('tar-fs')
, gunzip = require('gunzip-maybe')
, babel = require('babel-core')
, babel = require('@babel/core')
, glob = require('glob')
, pump = require('pump')
, rimraf = require('rimraf')
Expand Down Expand Up @@ -63,20 +63,21 @@ function processFile (inputLoc, out, replacements, addAtEnd) {
try {
const transformed = babel.transform(data, {
plugins: [
'transform-es2015-parameters',
'transform-es2015-arrow-functions',
'transform-es2015-block-scoping',
'transform-es2015-template-literals',
'transform-es2015-shorthand-properties',
'transform-es2015-for-of',
['transform-es2015-classes', { loose: true }],
'transform-es2015-destructuring',
'transform-es2015-computed-properties',
'transform-es2015-spread',
'transform-optional-catch-binding',
'transform-inline-imports-commonjs',
'transform-async-to-generator',
'transform-async-generator-functions'
'@babel/plugin-transform-parameters',
'@babel/plugin-transform-arrow-functions',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-transform-block-scoping',
'@babel/plugin-transform-template-literals',
'@babel/plugin-transform-shorthand-properties',
'@babel/plugin-transform-for-of',
['@babel/transform-classes', { loose: true }],
'@babel/plugin-transform-destructuring',
'@babel/plugin-transform-computed-properties',
'@babel/plugin-transform-spread',
'@babel/plugin-proposal-optional-catch-binding',
'@babel/plugin-transform-modules-commonjs',
'@babel/plugin-transform-async-to-generator',
'@babel/plugin-proposal-async-generator-functions'
]
})
data = transformed.code
Expand Down Expand Up @@ -159,6 +160,7 @@ pump(
file !== 'test-stream-inheritance.js' &&
file !== 'test-stream-base-prototype-accessors.js' &&
file !== 'test-stream-base-prototype-accessors-enumerability.js' &&
file !== 'test-stream-wrap-drain.js' &&
file !== 'test-stream-base-typechecking.js') {
processTestFile(file)
}
Expand Down
25 changes: 18 additions & 7 deletions build/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ function CorkedRequest(state) {
, 'if (typeof Symbol === \'function\' ) {\nReadable.prototype[Symbol.asyncIterator] = function () {'
]
, noAsyncIterators2 = [
/return new ReadableAsyncIterator\(this\);\n};/m
, 'return new ReadableAsyncIterator(this);\n};\n}'
/return createReadableStreamAsyncIterator\(this\);\n};/m
, 'return createReadableStreamAsyncIterator(this);\n};\n}'
]
, once = [
/const \{ once \} = require\('internal\/util'\);/
Expand Down Expand Up @@ -298,18 +298,17 @@ module.exports['_stream_writable.js'] = [
]

module.exports['internal/streams/buffer_list.js'] = [
[
/inspect.custom/g,
'custom'
],
[
/const \{ inspect \} = require\('util'\);/,
`
const { inspect } = require('util')
const custom = inspect && inspect.custom || 'inspect'
`
]
, [
/inspect.custom/g,
'custom'
]

]
module.exports['internal/streams/destroy.js'] = [
errorsTwoLevel
Expand All @@ -322,6 +321,18 @@ module.exports['internal/streams/state.js'] = [

module.exports['internal/streams/async_iterator.js'] = [
, errorsTwoLevel
, [
/internal\/streams\/end-of-stream/,
'./end-of-stream'
]
, [
/const AsyncIteratorPrototype = Object\.getPrototypeOf\(\n.*Object\.getPrototypeOf\(async function\* \(\) \{\}\).prototype\);/m,
'const AsyncIteratorPrototype = Object\.getPrototypeOf(function () {})'
]
, [
/ return\(\)/,
'[Symbol.asyncIterator]() { return this },\n return\(\)'
]
]

module.exports['internal/streams/end-of-stream.js'] = [
Expand Down
14 changes: 13 additions & 1 deletion build/test-replacements.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ module.exports['common.js'] = [
, [
/^/,
`/*<replacement>*/
require('babel-polyfill');
require('@babel/polyfill');
var util = require('util');
for (var i in util) exports[i] = util[i];
/*</replacement>*/`
Expand Down Expand Up @@ -317,6 +317,10 @@ module.exports['test-stream2-readable-from-list.js'] = [
[
/require\('internal\/streams\/buffer_list'\)/,
'require(\'../../lib/internal/streams/buffer_list\')'
],
[
/assert\.strictEqual\(\n *util.inspect\(\[ list \], \{ compact: false \}\),\n *`\[\n *BufferList \{\n *head: \[Object\],\n *tail: \[Object\],\n *length: 4\n *\}\n *\]`\);/m,
'assert.strictEqual(util.inspect([ list ], { compact: false }).indexOf(\'BufferList\') > 0, true)'
]
]
module.exports['test-stream-writev.js'] = [
Expand Down Expand Up @@ -438,5 +442,13 @@ module.exports['test-stream-readable-async-iterators.js'] = [
[
/assert.rejects\(/g,
'(function(f, e) { let success = false; f().then(function() { success = true; throw new Error(\'should not succeeed\') }).catch(function(e2) { if (success) { throw e2; } assert.strictEqual(e.message, e2.message); })})('
],
[
/tests\(\).then\(common\.mustCall\(\)\)/,
'tests().then(common.mustCall(), common.mustNotCall(console.log))'
],
[
/const AsyncIteratorPrototype = Object\.getPrototypeOf\(\n.*Object\.getPrototypeOf\(async function\* \(\) \{\}\).prototype\);/m,
'const AsyncIteratorPrototype = Object\.getPrototypeOf(function () {})'
]
]
58 changes: 34 additions & 24 deletions errors-browser.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
'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 _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

var codes = {};

Expand All @@ -23,57 +29,60 @@ function createErrorType(code, message, Base) {
}
}

var NodeError = function (_Base) {
var NodeError =
/*#__PURE__*/
function (_Base) {
_inherits(NodeError, _Base);

function NodeError(arg1, arg2, arg3) {
_classCallCheck(this, NodeError);

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

return NodeError;
}(Base);

NodeError.prototype.name = Base.name;
NodeError.prototype.code = code;

codes[code] = NodeError;
}
} // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js


// 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];
return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1];
} else if (len === 2) {
return 'one of ' + thing + ' ' + expected[0] + ' or ' + expected[1];
return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]);
} else {
return 'of ' + thing + ' ' + expected[0];
return "of ".concat(thing, " ").concat(expected[0]);
}
} else {
return 'of ' + thing + ' ' + String(expected);
return "of ".concat(thing, " ").concat(String(expected));
}
}
} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith


// 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


// 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


// 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;
Expand All @@ -91,24 +100,26 @@ createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {
}, TypeError);
createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {
// determiner: 'must be' or 'must not be'
var determiner = void 0;
var determiner;

if (typeof expected === 'string' && startsWith(expected, 'not ')) {
determiner = 'must not be';
expected = expected.replace(/^not /, '');
} else {
determiner = 'must be';
}

var msg = void 0;
var msg;

if (endsWith(name, ' argument')) {
// For cases like 'first argument'
msg = 'The ' + name + ' ' + determiner + ' ' + oneOf(expected, 'type');
msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
} else {
var type = includes(name, '.') ? 'property' : 'argument';
msg = 'The "' + name + '" ' + type + ' ' + determiner + ' ' + oneOf(expected, 'type');
msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
}

msg += '. Received type ' + (typeof actual === 'undefined' ? 'undefined' : _typeof(actual));
msg += ". Received type ".concat(_typeof(actual));
return msg;
}, TypeError);
createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');
Expand All @@ -127,5 +138,4 @@ createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
return 'Unknown encoding: ' + arg;
}, TypeError);
createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');

module.exports.codes = codes;
30 changes: 14 additions & 16 deletions lib/_stream_duplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,37 @@
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

// a duplex stream is just a stream that is both readable and writable.
// Since JS doesn't have multiple prototypal inheritance, this class
// prototypally inherits from Readable, and then parasitically from
// Writable.

'use strict';

/*<replacement>*/

var objectKeys = Object.keys || function (obj) {
var keys = [];

for (var key in obj) {
keys.push(key);
}return keys;
}

return keys;
};
/*</replacement>*/


module.exports = Duplex;

var Readable = require('./_stream_readable');

var Writable = require('./_stream_writable');

require('inherits')(Duplex, Readable);

{
// Allow the keys array to be GC'ed.
var keys = objectKeys(Writable.prototype);

for (var v = 0; v < keys.length; v++) {
var method = keys[v];
if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
Expand All @@ -54,14 +57,12 @@ require('inherits')(Duplex, Readable);

function Duplex(options) {
if (!(this instanceof Duplex)) return new Duplex(options);

Readable.call(this, options);
Writable.call(this, options);
this.allowHalfOpen = true;

if (options) {
if (options.readable === false) this.readable = false;

if (options.writable === false) this.writable = false;

if (options.allowHalfOpen === false) {
Expand All @@ -80,7 +81,6 @@ Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
return this._writableState.highWaterMark;
}
});

Object.defineProperty(Duplex.prototype, 'writableBuffer', {
// making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
Expand All @@ -90,7 +90,6 @@ Object.defineProperty(Duplex.prototype, 'writableBuffer', {
return this._writableState && this._writableState.getBuffer();
}
});

Object.defineProperty(Duplex.prototype, 'writableLength', {
// making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
Expand All @@ -99,15 +98,13 @@ Object.defineProperty(Duplex.prototype, 'writableLength', {
get: function () {
return this._writableState.length;
}
});
}); // the no-half-open enforcer

// the no-half-open enforcer
function onend() {
// If the writable side ended, then we're ok.
if (this._writableState.ended) return;

// no more data can be written.
if (this._writableState.ended) return; // no more data can be written.
// But allow more writes to happen in this tick.

process.nextTick(onEndNT, this);
}

Expand All @@ -124,17 +121,18 @@ Object.defineProperty(Duplex.prototype, 'destroyed', {
if (this._readableState === undefined || this._writableState === undefined) {
return false;
}

return this._readableState.destroyed && this._writableState.destroyed;
},
set: function (value) {
// we ignore the value if the stream
// has not been initialized yet
if (this._readableState === undefined || this._writableState === undefined) {
return;
}

// backward compatibility, the user is explicitly
} // backward compatibility, the user is explicitly
// managing destroyed


this._readableState.destroyed = value;
this._writableState.destroyed = value;
}
Expand Down
Loading