Skip to content

Commit

Permalink
Updated to node v7.10.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Jun 2, 2017
1 parent a449bc8 commit a77f329
Show file tree
Hide file tree
Showing 9 changed files with 195 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ node_modules/
.zuul.yml
.nyc_output
coverage
package-lock.json
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sudo: false
language: node_js
before_install:
- npm install -g npm@2
- npm install -g npm
- npm install -g npm@4
notifications:
email: false
matrix:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/v7.8.0/docs/api/stream.html).
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v7.10.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
1 change: 1 addition & 0 deletions build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function processFile (inputLoc, out, replacements) {
'transform-es2015-template-literals',
'transform-es2015-shorthand-properties',
'transform-es2015-for-of',
'transform-es2015-classes',
'transform-es2015-destructuring'
]
})
Expand Down
15 changes: 8 additions & 7 deletions build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@
"description": "",
"main": "build.js",
"dependencies": {
"babel-core": "^6.5.2",
"babel-core": "^6.24.1",
"babel-plugin-transform-es2015-arrow-functions": "^6.5.2",
"babel-plugin-transform-es2015-block-scoping": "^6.5.0",
"babel-plugin-transform-es2015-block-scoping": "^6.24.1",
"babel-plugin-transform-es2015-classes": "^6.24.1",
"babel-plugin-transform-es2015-destructuring": "^6.18.0",
"babel-plugin-transform-es2015-for-of": "^6.8.0",
"babel-plugin-transform-es2015-parameters": "^6.11.4",
"babel-plugin-transform-es2015-shorthand-properties": "^6.8.0",
"babel-plugin-transform-es2015-parameters": "^6.24.1",
"babel-plugin-transform-es2015-shorthand-properties": "^6.24.1",
"babel-plugin-transform-es2015-template-literals": "^6.8.0",
"bl": "^1.2.0",
"glob": "^7.1.1",
"bl": "^1.2.1",
"glob": "^7.1.2",
"gunzip-maybe": "^1.4.0",
"hyperquest": "^2.1.2",
"pump": "^1.0.2",
"rimraf": "^2.6.1",
"tar-fs": "^1.15.1"
"tar-fs": "^1.15.2"
}
}
4 changes: 2 additions & 2 deletions lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ Readable.prototype.pipe = function (dest, pipeOpts) {

var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;

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

dest.on('unpipe', onunpipe);
Expand Down Expand Up @@ -515,7 +515,7 @@ Readable.prototype.pipe = function (dest, pipeOpts) {
dest.removeListener('error', onerror);
dest.removeListener('unpipe', onunpipe);
src.removeListener('end', onend);
src.removeListener('end', cleanup);
src.removeListener('end', unpipe);
src.removeListener('data', ondata);

cleanedUp = true;
Expand Down
44 changes: 38 additions & 6 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ if (global.__coverage__) knownGlobals.push(__coverage__);
function leakedGlobals() {
var leaked = [];

// eslint-disable-next-line no-var
for (var val in global) {
if (!knownGlobals.includes(global[val])) leaked.push(val);
}if (global.__coverage__) {
Expand Down Expand Up @@ -564,15 +565,46 @@ exports.isAlive = function isAlive(pid) {
}
};

exports.expectWarning = function (name, expected) {
if (typeof expected === 'string') expected = [expected];
process.on('warning', exports.mustCall(function (warning) {
function expectWarning(name, expectedMessages) {
return exports.mustCall(function (warning) {
assert.strictEqual(warning.name, name);
assert.ok(expected.includes(warning.message), 'unexpected error message: "' + warning.message + '"');
assert.ok(expectedMessages.includes(warning.message), 'unexpected error message: "' + warning.message + '"');
// Remove a warning message after it is seen so that we guarantee that we
// get each message only once.
expected.splice(expected.indexOf(warning.message), 1);
}, expected.length));
expectedMessages.splice(expectedMessages.indexOf(warning.message), 1);
}, expectedMessages.length);
}

function expectWarningByName(name, expected) {
if (typeof expected === 'string') {
expected = [expected];
}
process.on('warning', expectWarning(name, expected));
}

function expectWarningByMap(warningMap) {
var catchWarning = {};
forEach(objectKeys(warningMap), function (name) {
var expected = warningMap[name];
if (typeof expected === 'string') {
expected = [expected];
}
catchWarning[name] = expectWarning(name, expected);
});
process.on('warning', function (warning) {
return catchWarning[warning.name](warning);
});
}

// accepts a warning name and description or array of descriptions or a map
// of warning names to description(s)
// ensures a warning is generated for each name/description pair
exports.expectWarning = function (nameOrMap, expected) {
if (typeof nameOrMap === 'string') {
expectWarningByName(nameOrMap, expected);
} else {
expectWarningByMap(nameOrMap);
}
};

/*<replacement>*/if (!process.browser) {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-stream-duplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var bufferShim = require('safe-buffer').Buffer;
/*</replacement>*/
require('../common');
var assert = require('assert/');
var Duplex = require('../../').Transform;
var Duplex = require('../../').Duplex;

var stream = new Duplex({ objectMode: true });

Expand Down
142 changes: 142 additions & 0 deletions test/parallel/test-stream-unpipe-event.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
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; }; }();

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 _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; }

/*<replacement>*/
var bufferShim = require('safe-buffer').Buffer;
/*</replacement>*/
var common = require('../common');
var assert = require('assert/');

var _require = require('../../'),
Writable = _require.Writable,
Readable = _require.Readable;

var NullWriteable = function (_Writable) {
_inherits(NullWriteable, _Writable);

function NullWriteable() {
_classCallCheck(this, NullWriteable);

return _possibleConstructorReturn(this, (NullWriteable.__proto__ || Object.getPrototypeOf(NullWriteable)).apply(this, arguments));
}

_createClass(NullWriteable, [{
key: '_write',
value: function _write(chunk, encoding, callback) {
return callback();
}
}]);

return NullWriteable;
}(Writable);

var QuickEndReadable = function (_Readable) {
_inherits(QuickEndReadable, _Readable);

function QuickEndReadable() {
_classCallCheck(this, QuickEndReadable);

return _possibleConstructorReturn(this, (QuickEndReadable.__proto__ || Object.getPrototypeOf(QuickEndReadable)).apply(this, arguments));
}

_createClass(QuickEndReadable, [{
key: '_read',
value: function _read() {
this.push(null);
}
}]);

return QuickEndReadable;
}(Readable);

var NeverEndReadable = function (_Readable2) {
_inherits(NeverEndReadable, _Readable2);

function NeverEndReadable() {
_classCallCheck(this, NeverEndReadable);

return _possibleConstructorReturn(this, (NeverEndReadable.__proto__ || Object.getPrototypeOf(NeverEndReadable)).apply(this, arguments));
}

_createClass(NeverEndReadable, [{
key: '_read',
value: function _read() {}
}]);

return NeverEndReadable;
}(Readable);

function noop() {}

{
var dest = new NullWriteable();
var src = new QuickEndReadable();
dest.on('pipe', common.mustCall(noop));
dest.on('unpipe', common.mustCall(noop));
src.pipe(dest);
setImmediate(function () {
assert.strictEqual(src._readableState.pipesCount, 0);
});
}

{
var _dest = new NullWriteable();
var _src = new NeverEndReadable();
_dest.on('pipe', common.mustCall(noop));
_dest.on('unpipe', common.mustNotCall('unpipe should not have been emitted'));
_src.pipe(_dest);
setImmediate(function () {
assert.strictEqual(_src._readableState.pipesCount, 1);
});
}

{
var _dest2 = new NullWriteable();
var _src2 = new NeverEndReadable();
_dest2.on('pipe', common.mustCall(noop));
_dest2.on('unpipe', common.mustCall(noop));
_src2.pipe(_dest2);
_src2.unpipe(_dest2);
setImmediate(function () {
assert.strictEqual(_src2._readableState.pipesCount, 0);
});
}

{
var _dest3 = new NullWriteable();
var _src3 = new QuickEndReadable();
_dest3.on('pipe', common.mustCall(noop));
_dest3.on('unpipe', common.mustCall(noop));
_src3.pipe(_dest3, { end: false });
setImmediate(function () {
assert.strictEqual(_src3._readableState.pipesCount, 0);
});
}

{
var _dest4 = new NullWriteable();
var _src4 = new NeverEndReadable();
_dest4.on('pipe', common.mustCall(noop));
_dest4.on('unpipe', common.mustNotCall('unpipe should not have been emitted'));
_src4.pipe(_dest4, { end: false });
setImmediate(function () {
assert.strictEqual(_src4._readableState.pipesCount, 1);
});
}

{
var _dest5 = new NullWriteable();
var _src5 = new NeverEndReadable();
_dest5.on('pipe', common.mustCall(noop));
_dest5.on('unpipe', common.mustCall(noop));
_src5.pipe(_dest5, { end: false });
_src5.unpipe(_dest5);
setImmediate(function () {
assert.strictEqual(_src5._readableState.pipesCount, 0);
});
}

0 comments on commit a77f329

Please sign in to comment.