Skip to content

Commit

Permalink
Updated to Node 10.5.0. 2 failures left to go.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Jun 25, 2018
1 parent 3754ff4 commit b87f8a2
Show file tree
Hide file tree
Showing 127 changed files with 1,717 additions and 626 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# readable-stream

***Node-core v10.3.0 streams for userland*** [![Build Status](https://travis-ci.org/nodejs/readable-stream.svg?branch=master)](https://travis-ci.org/nodejs/readable-stream)
***Node-core v10.5.0 streams for userland*** [![Build Status](https://travis-ci.org/nodejs/readable-stream.svg?branch=master)](https://travis-ci.org/nodejs/readable-stream)


[![NPM](https://nodei.co/npm/readable-stream.png?downloads=true&downloadRank=true)](https://nodei.co/npm/readable-stream/)
Expand All @@ -18,7 +18,7 @@ npm install --save readable-stream
This package is a mirror of the Streams2 and Streams3 implementations in
Node-core.

Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v10.3.0/docs/api/stream.html).
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v10.5.0/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
7 changes: 5 additions & 2 deletions build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,14 @@ function processFile (inputLoc, out, replacements, addAtEnd) {
'transform-es2015-template-literals',
'transform-es2015-shorthand-properties',
'transform-es2015-for-of',
'transform-async-generator-functions',
['transform-es2015-classes', { loose: true }],
'transform-es2015-destructuring',
'transform-es2015-computed-properties',
'transform-es2015-spread'
'transform-es2015-spread',
'transform-optional-catch-binding',
'transform-inline-imports-commonjs',
'transform-async-generator-functions',
'transform-runtime',
]
})
data = transformed.code
Expand Down
2 changes: 2 additions & 0 deletions build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"babel-plugin-transform-es2015-shorthand-properties": "^6.24.1",
"babel-plugin-transform-es2015-spread": "^6.22.0",
"babel-plugin-transform-es2015-template-literals": "^6.8.0",
"babel-plugin-transform-inline-imports-commonjs": "^1.2.0",
"babel-plugin-transform-runtime": "^6.23.0",
"bl": "^2.0.0",
"glob": "^7.1.2",
"gunzip-maybe": "^1.4.1",
Expand Down
107 changes: 68 additions & 39 deletions build/test-replacements.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@ const altForEachImplReplacement = require('./common-replacements').altForEachImp
/util\.isDeepStrictEqual/,
'require(\'deep-strict-equal\')'
]
, tapOk = [
/console\.log\('ok'\);/g,
'require(\'tap\').pass();'
]
, catchES7 = [
/} catch {/,
'} catch(_e) {'
]
, catchES7OpenClose = [
/} catch {}/,
'} catch(_e) {}'
]


module.exports.all = [
Expand Down Expand Up @@ -91,27 +103,8 @@ module.exports['common.js'] = [
, altForEachImplReplacement
, altForEachUseReplacement
, deepStrictEqual

, [
/(exports.mustCall[\s\S]*)/m
, '$1\n'
+ 'if (!util._errnoException) {\n'
+ ' var uv;\n'
+ ' util._errnoException = function(err, syscall) {\n'
+ ' if (util.isUndefined(uv)) try { uv = process.binding(\'uv\'); } catch (e) {}\n'
+ ' var errname = uv ? uv.errname(err) : \'\';\n'
+ ' var e = new Error(syscall + \' \' + errname);\n'
+ ' e.code = errname;\n'
+ ' e.errno = errname;\n'
+ ' e.syscall = syscall;\n'
+ ' return e;\n'
+ ' };\n'
+ '}\n'
]

// for streams2 on node 0.11
// and dtrace in 0.10
// and coverage in all
, catchES7
, catchES7OpenClose
, [
/^( for \(var x in global\) \{|function leakedGlobals\(\) \{)$/m
, ' /*<replacement>*/\n'
Expand All @@ -123,27 +116,27 @@ module.exports['common.js'] = [
+ ' knownGlobals.push(DTRACE_NET_SOCKET_WRITE);\n'
+ ' if (global.__coverage__)\n'
+ ' knownGlobals.push(__coverage__);\n'
+ '\'core,__core-js_shared__,console,Promise,Map,Set,WeakMap,WeakSet,Reflect,System,asap,Observable,regeneratorRuntime,_babelPolyfill\'.split(\',\').filter(function (item) { return typeof global[item] !== undefined}).forEach(function (item) {knownGlobals.push(global[item])})'
+ '\'console,clearImmediate,setImmediate,core,__core-js_shared__,Promise,Map,Set,WeakMap,WeakSet,Reflect,System,asap,Observable,regeneratorRuntime,_babelPolyfill\'.split(\',\').filter(function (item) { return typeof global[item] !== undefined}).forEach(function (item) {knownGlobals.push(global[item])})'
+ ' /*</replacement>*/\n\n$1'
]

// for node 0.8
, [
/^/
, '/*<replacement>*/'
+ '\nif (!global.setImmediate) {\n'
+ ' global.setImmediate = function setImmediate(fn) {\n'

+ ' return setTimeout(fn.bind.apply(fn, arguments), 4);\n'
+ ' };\n'
+ '}\n'
+ 'if (!global.clearImmediate) {\n'
+ ' global.clearImmediate = function clearImmediate(i) {\n'
+ ' return clearTimeout(i);\n'
/(exports.mustCall[\s\S]*)/m
, '$1\n'
+ 'if (!util._errnoException) {\n'
+ ' var uv;\n'
+ ' util._errnoException = function(err, syscall) {\n'
+ ' if (util.isUndefined(uv)) try { uv = process.binding(\'uv\'); } catch (e) {}\n'
+ ' var errname = uv ? uv.errname(err) : \'\';\n'
+ ' var e = new Error(syscall + \' \' + errname);\n'
+ ' e.code = errname;\n'
+ ' e.errno = errname;\n'
+ ' e.syscall = syscall;\n'
+ ' return e;\n'
+ ' };\n'
+ '}\n'
+ '/*</replacement>*/\n'
]

, [
/^if \(global\.ArrayBuffer\) \{([^\}]+)\}$/m
, '/*<replacement>*/if (!process.browser) {'
Expand Down Expand Up @@ -319,16 +312,51 @@ module.exports['test-stream2-readable-from-list.js'] = [
]
]
module.exports['test-stream-writev.js'] = [
[
/console\.log\('ok'\);/,
'require(\'tap\').pass();'
],
tapOk,
[
/console.log\(`# decode=/,
'require(\'tap\').test(`# decode='
]
]

module.exports['test-stream3-pause-then-read.js'] = [
tapOk
]

module.exports['test-stream-unshift-read-race.js'] = [
tapOk
]

module.exports['test-stream2-unpipe-leak.js'] = [
tapOk
]

module.exports['test-stream2-compatibility.js'] = [
tapOk
]

module.exports['test-stream-push-strings.js'] = [
tapOk
]

module.exports['test-stream-unshift-empty-chunk.js'] = [
tapOk
]

module.exports['test-stream2-pipe-error-once-listener.js'] = [
tapOk
]

module.exports['test-stream-push-order.js'] = [
tapOk
]

module.exports['test-stream2-push.js'] = [
tapOk
]

module.exports['test-stream2-readable-empty-buffer-no-eof.js'] = [
tapOk,
[
/case 3:\n(\s+)setImmediate\(r\.read\.bind\(r, 0\)\);/,
'case 3:\n$1setTimeout(r.read.bind(r, 0), 50);'
Expand Down Expand Up @@ -356,6 +384,7 @@ module.exports['test-stream-unpipe-event.js'] = [
]

module.exports['test-stream-readable-flow-recursion.js'] = [
tapOk,
deepStrictEqual
]

Expand Down
12 changes: 9 additions & 3 deletions errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,20 @@ function createErrorType(code, message, Base) {
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');
createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream-push() after EOF');
createErrorType('ERR_METHOD_NOT_IMPLEMENTED', 'the method is not implemented');
createErrorType('ERR_INVALID_ARG_TYPE', 'argument must be of the right type', TypeError);
createErrorType('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF');
createErrorType('ERR_METHOD_NOT_IMPLEMENTED', function (name) {
return 'The ' + name + ' method is not implemented'
});
createErrorType('ERR_STREAM_PREMATURE_CLOSE', 'premature close');
createErrorType('ERR_STREAM_DESTROYED', 'the stream was destroyed');
createErrorType('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times');
createErrorType('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable');
createErrorType('ERR_STREAM_WRITE_AFTER_END', 'write after end');
createErrorType('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError);
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;
10 changes: 9 additions & 1 deletion lib/_stream_duplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,19 @@

/*<replacement>*/

var _keys;

function _load_keys() {
return _keys = _interopRequireDefault(require('babel-runtime/core-js/object/keys'));
}

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

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

/*<replacement>*/
var objectKeys = Object.keys || function (obj) {
var objectKeys = (_keys || _load_keys()).default || function (obj) {
var keys = [];
for (var key in obj) {
keys.push(key);
Expand Down
42 changes: 27 additions & 15 deletions lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@

/*<replacement>*/

var _symbol;

function _load_symbol() {
return _symbol = _interopRequireDefault(require('babel-runtime/core-js/symbol'));
}

var _isNan;

function _load_isNan() {
return _isNan = _interopRequireDefault(require('babel-runtime/core-js/number/is-nan'));
}

var _getPrototypeOf;

function _load_getPrototypeOf() {
return _getPrototypeOf = _interopRequireDefault(require('babel-runtime/core-js/object/get-prototype-of'));
}

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

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

Expand Down Expand Up @@ -278,7 +298,7 @@ function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
if (er) {
stream.emit('error', er);
} else if (state.objectMode || chunk && chunk.length > 0) {
if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
if (typeof chunk !== 'string' && !state.objectMode && (0, (_getPrototypeOf || _load_getPrototypeOf()).default)(chunk) !== Buffer.prototype) {
chunk = _uint8ArrayToBuffer(chunk);
}

Expand All @@ -303,7 +323,10 @@ function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
}
}

return needMoreData(state);
// We can push more data if we are below the highWaterMark.
// Also, if we have no data yet, we can stand some more bytes.
// This is to work around cases where hwm=0, such as the repl.
return !state.ended && (state.length < state.highWaterMark || state.length === 0);
}

function addChunk(stream, state, chunk, addToFront) {
Expand All @@ -328,17 +351,6 @@ function chunkInvalid(state, chunk) {
return er;
}

// We can push more data if we are below the highWaterMark.
// Also, if we have no data yet, we can stand some
// more bytes. This is to work around cases where hwm=0,
// such as the repl. Also, if the push() triggered a
// readable event, and the user called read(largeNumber) such that
// needReadable was set, then we ought to push more, so that another
// 'readable' event will be triggered.
function needMoreData(state) {
return !state.ended && (state.length < state.highWaterMark || state.length === 0);
}

Readable.prototype.isPaused = function () {
return this._readableState.flowing === false;
};
Expand Down Expand Up @@ -376,7 +388,7 @@ function computeNewHighWaterMark(n) {
function howMuchToRead(n, state) {
if (n <= 0 || state.length === 0 && state.ended) return 0;
if (state.objectMode) return 1;
if (Number.isNaN(n)) {
if ((0, (_isNan || _load_isNan()).default)(n)) {
// Only flow one buffer at a time
if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
}
Expand Down Expand Up @@ -955,7 +967,7 @@ Readable.prototype.wrap = function (stream) {
return this;
};

Readable.prototype[Symbol.asyncIterator] = function () {
Readable.prototype[(_symbol || _load_symbol()).default.asyncIterator] = function () {
emitExperimentalWarning('Readable[Symbol.asyncIterator]');
if (ReadableAsyncIterator === undefined) ReadableAsyncIterator = require('./internal/streams/async_iterator');
return new ReadableAsyncIterator(this);
Expand Down
34 changes: 30 additions & 4 deletions lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,32 @@

/*<replacement>*/

var _defineProperty;

function _load_defineProperty() {
return _defineProperty = _interopRequireDefault(require('babel-runtime/core-js/object/define-property'));
}

var _hasInstance;

function _load_hasInstance() {
return _hasInstance = _interopRequireDefault(require('babel-runtime/core-js/symbol/has-instance'));
}

var _symbol;

function _load_symbol() {
return _symbol = _interopRequireDefault(require('babel-runtime/core-js/symbol'));
}

var _setImmediate2;

function _load_setImmediate() {
return _setImmediate2 = _interopRequireDefault(require('babel-runtime/core-js/set-immediate'));
}

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

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

Expand Down Expand Up @@ -54,7 +80,7 @@ function CorkedRequest(state) {
/* </replacement> */

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

/*<replacement>*/
Expand Down Expand Up @@ -240,9 +266,9 @@ WritableState.prototype.getBuffer = function getBuffer() {
// Test _writableState for inheritance to account for Duplex streams,
// whose prototype chain only points to Readable.
var realHasInstance;
if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
realHasInstance = Function.prototype[Symbol.hasInstance];
Object.defineProperty(Writable, Symbol.hasInstance, {
if (typeof (_symbol || _load_symbol()).default === 'function' && (_hasInstance || _load_hasInstance()).default && typeof Function.prototype[(_hasInstance || _load_hasInstance()).default] === 'function') {
realHasInstance = Function.prototype[(_hasInstance || _load_hasInstance()).default];
(0, (_defineProperty || _load_defineProperty()).default)(Writable, (_hasInstance || _load_hasInstance()).default, {
value: function (object) {
if (realHasInstance.call(this, object)) return true;
if (this !== Writable) return false;
Expand Down
Loading

0 comments on commit b87f8a2

Please sign in to comment.