Skip to content

Commit 1448d47

Browse files
authored
Updated to @babel/core@7, node 10.14.2 (#393)
* Updated to @babel/core@7, node 10.14.2 Fixes: #392 * use @babel/polyfill in the tests * Fixed missing babel deps * test passing on Node 8.
1 parent 51d6ab7 commit 1448d47

File tree

138 files changed

+5311
-3236
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+5311
-3236
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ npm install --save readable-stream
1515

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

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

2020
If you want to guarantee a stable streams base, regardless of what version of
2121
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).

build/build.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const hyperquest = require('hyperquest')
66
, path = require('path')
77
, tar = require('tar-fs')
88
, gunzip = require('gunzip-maybe')
9-
, babel = require('babel-core')
9+
, babel = require('@babel/core')
1010
, glob = require('glob')
1111
, pump = require('pump')
1212
, rimraf = require('rimraf')
@@ -63,20 +63,21 @@ function processFile (inputLoc, out, replacements, addAtEnd) {
6363
try {
6464
const transformed = babel.transform(data, {
6565
plugins: [
66-
'transform-es2015-parameters',
67-
'transform-es2015-arrow-functions',
68-
'transform-es2015-block-scoping',
69-
'transform-es2015-template-literals',
70-
'transform-es2015-shorthand-properties',
71-
'transform-es2015-for-of',
72-
['transform-es2015-classes', { loose: true }],
73-
'transform-es2015-destructuring',
74-
'transform-es2015-computed-properties',
75-
'transform-es2015-spread',
76-
'transform-optional-catch-binding',
77-
'transform-inline-imports-commonjs',
78-
'transform-async-to-generator',
79-
'transform-async-generator-functions'
66+
'@babel/plugin-transform-parameters',
67+
'@babel/plugin-transform-arrow-functions',
68+
'@babel/plugin-proposal-object-rest-spread',
69+
'@babel/plugin-transform-block-scoping',
70+
'@babel/plugin-transform-template-literals',
71+
'@babel/plugin-transform-shorthand-properties',
72+
'@babel/plugin-transform-for-of',
73+
['@babel/transform-classes', { loose: true }],
74+
'@babel/plugin-transform-destructuring',
75+
'@babel/plugin-transform-computed-properties',
76+
'@babel/plugin-transform-spread',
77+
'@babel/plugin-proposal-optional-catch-binding',
78+
'@babel/plugin-transform-modules-commonjs',
79+
'@babel/plugin-transform-async-to-generator',
80+
'@babel/plugin-proposal-async-generator-functions'
8081
]
8182
})
8283
data = transformed.code
@@ -159,6 +160,7 @@ pump(
159160
file !== 'test-stream-inheritance.js' &&
160161
file !== 'test-stream-base-prototype-accessors.js' &&
161162
file !== 'test-stream-base-prototype-accessors-enumerability.js' &&
163+
file !== 'test-stream-wrap-drain.js' &&
162164
file !== 'test-stream-base-typechecking.js') {
163165
processTestFile(file)
164166
}

build/files.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ function CorkedRequest(state) {
205205
, 'if (typeof Symbol === \'function\' ) {\nReadable.prototype[Symbol.asyncIterator] = function () {'
206206
]
207207
, noAsyncIterators2 = [
208-
/return new ReadableAsyncIterator\(this\);\n};/m
209-
, 'return new ReadableAsyncIterator(this);\n};\n}'
208+
/return createReadableStreamAsyncIterator\(this\);\n};/m
209+
, 'return createReadableStreamAsyncIterator(this);\n};\n}'
210210
]
211211
, once = [
212212
/const \{ once \} = require\('internal\/util'\);/
@@ -298,18 +298,17 @@ module.exports['_stream_writable.js'] = [
298298
]
299299

300300
module.exports['internal/streams/buffer_list.js'] = [
301+
[
302+
/inspect.custom/g,
303+
'custom'
304+
],
301305
[
302306
/const \{ inspect \} = require\('util'\);/,
303307
`
304308
const { inspect } = require('util')
305309
const custom = inspect && inspect.custom || 'inspect'
306310
`
307311
]
308-
, [
309-
/inspect.custom/g,
310-
'custom'
311-
]
312-
313312
]
314313
module.exports['internal/streams/destroy.js'] = [
315314
errorsTwoLevel
@@ -322,6 +321,18 @@ module.exports['internal/streams/state.js'] = [
322321

323322
module.exports['internal/streams/async_iterator.js'] = [
324323
, errorsTwoLevel
324+
, [
325+
/internal\/streams\/end-of-stream/,
326+
'./end-of-stream'
327+
]
328+
, [
329+
/const AsyncIteratorPrototype = Object\.getPrototypeOf\(\n.*Object\.getPrototypeOf\(async function\* \(\) \{\}\).prototype\);/m,
330+
'const AsyncIteratorPrototype = Object\.getPrototypeOf(function () {})'
331+
]
332+
, [
333+
/ return\(\)/,
334+
'[Symbol.asyncIterator]() { return this },\n return\(\)'
335+
]
325336
]
326337

327338
module.exports['internal/streams/end-of-stream.js'] = [

build/test-replacements.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ module.exports['common.js'] = [
156156
, [
157157
/^/,
158158
`/*<replacement>*/
159-
require('babel-polyfill');
159+
require('@babel/polyfill');
160160
var util = require('util');
161161
for (var i in util) exports[i] = util[i];
162162
/*</replacement>*/`
@@ -317,6 +317,10 @@ module.exports['test-stream2-readable-from-list.js'] = [
317317
[
318318
/require\('internal\/streams\/buffer_list'\)/,
319319
'require(\'../../lib/internal/streams/buffer_list\')'
320+
],
321+
[
322+
/assert\.strictEqual\(\n *util.inspect\(\[ list \], \{ compact: false \}\),\n *`\[\n *BufferList \{\n *head: \[Object\],\n *tail: \[Object\],\n *length: 4\n *\}\n *\]`\);/m,
323+
'assert.strictEqual(util.inspect([ list ], { compact: false }).indexOf(\'BufferList\') > 0, true)'
320324
]
321325
]
322326
module.exports['test-stream-writev.js'] = [
@@ -438,5 +442,13 @@ module.exports['test-stream-readable-async-iterators.js'] = [
438442
[
439443
/assert.rejects\(/g,
440444
'(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); })})('
445+
],
446+
[
447+
/tests\(\).then\(common\.mustCall\(\)\)/,
448+
'tests().then(common.mustCall(), common.mustNotCall(console.log))'
449+
],
450+
[
451+
/const AsyncIteratorPrototype = Object\.getPrototypeOf\(\n.*Object\.getPrototypeOf\(async function\* \(\) \{\}\).prototype\);/m,
452+
'const AsyncIteratorPrototype = Object\.getPrototypeOf(function () {})'
441453
]
442454
]

errors-browser.js

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
'use strict';
22

3-
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; };
3+
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); }
44

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

7-
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; }
7+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
88

9-
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; }
9+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
10+
11+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
12+
13+
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); }
14+
15+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
1016

1117
var codes = {};
1218

@@ -23,57 +29,60 @@ function createErrorType(code, message, Base) {
2329
}
2430
}
2531

26-
var NodeError = function (_Base) {
32+
var NodeError =
33+
/*#__PURE__*/
34+
function (_Base) {
2735
_inherits(NodeError, _Base);
2836

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

32-
return _possibleConstructorReturn(this, (NodeError.__proto__ || Object.getPrototypeOf(NodeError)).call(this, getMessage(arg1, arg2, arg3)));
40+
return _possibleConstructorReturn(this, _getPrototypeOf(NodeError).call(this, getMessage(arg1, arg2, arg3)));
3341
}
3442

3543
return NodeError;
3644
}(Base);
3745

3846
NodeError.prototype.name = Base.name;
3947
NodeError.prototype.code = code;
40-
4148
codes[code] = NodeError;
42-
}
49+
} // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
50+
4351

44-
// https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js
4552
function oneOf(expected, thing) {
4653
if (Array.isArray(expected)) {
4754
var len = expected.length;
4855
expected = expected.map(function (i) {
4956
return String(i);
5057
});
58+
5159
if (len > 2) {
52-
return 'one of ' + thing + ' ' + expected.slice(0, len - 1).join(', ') + ', or ' + expected[len - 1];
60+
return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1];
5361
} else if (len === 2) {
54-
return 'one of ' + thing + ' ' + expected[0] + ' or ' + expected[1];
62+
return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]);
5563
} else {
56-
return 'of ' + thing + ' ' + expected[0];
64+
return "of ".concat(thing, " ").concat(expected[0]);
5765
}
5866
} else {
59-
return 'of ' + thing + ' ' + String(expected);
67+
return "of ".concat(thing, " ").concat(String(expected));
6068
}
61-
}
69+
} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
70+
6271

63-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith
6472
function startsWith(str, search, pos) {
6573
return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search;
66-
}
74+
} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
75+
6776

68-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith
6977
function endsWith(str, search, this_len) {
7078
if (this_len === undefined || this_len > str.length) {
7179
this_len = str.length;
7280
}
81+
7382
return str.substring(this_len - search.length, this_len) === search;
74-
}
83+
} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
84+
7585

76-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
7786
function includes(str, search, start) {
7887
if (typeof start !== 'number') {
7988
start = 0;
@@ -91,24 +100,26 @@ createErrorType('ERR_INVALID_OPT_VALUE', function (name, value) {
91100
}, TypeError);
92101
createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) {
93102
// determiner: 'must be' or 'must not be'
94-
var determiner = void 0;
103+
var determiner;
104+
95105
if (typeof expected === 'string' && startsWith(expected, 'not ')) {
96106
determiner = 'must not be';
97107
expected = expected.replace(/^not /, '');
98108
} else {
99109
determiner = 'must be';
100110
}
101111

102-
var msg = void 0;
112+
var msg;
113+
103114
if (endsWith(name, ' argument')) {
104115
// For cases like 'first argument'
105-
msg = 'The ' + name + ' ' + determiner + ' ' + oneOf(expected, 'type');
116+
msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
106117
} else {
107118
var type = includes(name, '.') ? 'property' : 'argument';
108-
msg = 'The "' + name + '" ' + type + ' ' + determiner + ' ' + oneOf(expected, 'type');
119+
msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type'));
109120
}
110121

111-
msg += '. Received type ' + (typeof actual === 'undefined' ? 'undefined' : _typeof(actual));
122+
msg += ". Received type ".concat(_typeof(actual));
112123
return msg;
113124
}, TypeError);
114125
createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');
@@ -127,5 +138,4 @@ createErrorType('ERR_UNKNOWN_ENCODING', function (arg) {
127138
return 'Unknown encoding: ' + arg;
128139
}, TypeError);
129140
createErrorType('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event');
130-
131141
module.exports.codes = codes;

lib/_stream_duplex.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,37 @@
1818
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
1919
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
21-
2221
// a duplex stream is just a stream that is both readable and writable.
2322
// Since JS doesn't have multiple prototypal inheritance, this class
2423
// prototypally inherits from Readable, and then parasitically from
2524
// Writable.
26-
2725
'use strict';
28-
2926
/*<replacement>*/
3027

3128
var objectKeys = Object.keys || function (obj) {
3229
var keys = [];
30+
3331
for (var key in obj) {
3432
keys.push(key);
35-
}return keys;
33+
}
34+
35+
return keys;
3636
};
3737
/*</replacement>*/
3838

39+
3940
module.exports = Duplex;
4041

4142
var Readable = require('./_stream_readable');
43+
4244
var Writable = require('./_stream_writable');
4345

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

4648
{
4749
// Allow the keys array to be GC'ed.
4850
var keys = objectKeys(Writable.prototype);
51+
4952
for (var v = 0; v < keys.length; v++) {
5053
var method = keys[v];
5154
if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
@@ -54,14 +57,12 @@ require('inherits')(Duplex, Readable);
5457

5558
function Duplex(options) {
5659
if (!(this instanceof Duplex)) return new Duplex(options);
57-
5860
Readable.call(this, options);
5961
Writable.call(this, options);
6062
this.allowHalfOpen = true;
6163

6264
if (options) {
6365
if (options.readable === false) this.readable = false;
64-
6566
if (options.writable === false) this.writable = false;
6667

6768
if (options.allowHalfOpen === false) {
@@ -80,7 +81,6 @@ Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
8081
return this._writableState.highWaterMark;
8182
}
8283
});
83-
8484
Object.defineProperty(Duplex.prototype, 'writableBuffer', {
8585
// making it explicit this property is not enumerable
8686
// because otherwise some prototype manipulation in
@@ -90,7 +90,6 @@ Object.defineProperty(Duplex.prototype, 'writableBuffer', {
9090
return this._writableState && this._writableState.getBuffer();
9191
}
9292
});
93-
9493
Object.defineProperty(Duplex.prototype, 'writableLength', {
9594
// making it explicit this property is not enumerable
9695
// because otherwise some prototype manipulation in
@@ -99,15 +98,13 @@ Object.defineProperty(Duplex.prototype, 'writableLength', {
9998
get: function () {
10099
return this._writableState.length;
101100
}
102-
});
101+
}); // the no-half-open enforcer
103102

104-
// the no-half-open enforcer
105103
function onend() {
106104
// If the writable side ended, then we're ok.
107-
if (this._writableState.ended) return;
108-
109-
// no more data can be written.
105+
if (this._writableState.ended) return; // no more data can be written.
110106
// But allow more writes to happen in this tick.
107+
111108
process.nextTick(onEndNT, this);
112109
}
113110

@@ -124,17 +121,18 @@ Object.defineProperty(Duplex.prototype, 'destroyed', {
124121
if (this._readableState === undefined || this._writableState === undefined) {
125122
return false;
126123
}
124+
127125
return this._readableState.destroyed && this._writableState.destroyed;
128126
},
129127
set: function (value) {
130128
// we ignore the value if the stream
131129
// has not been initialized yet
132130
if (this._readableState === undefined || this._writableState === undefined) {
133131
return;
134-
}
135-
136-
// backward compatibility, the user is explicitly
132+
} // backward compatibility, the user is explicitly
137133
// managing destroyed
134+
135+
138136
this._readableState.destroyed = value;
139137
this._writableState.destroyed = value;
140138
}

0 commit comments

Comments
 (0)