Skip to content

Commit

Permalink
Import from Node 8.1.2.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Jun 21, 2017
1 parent a7f526f commit cf1657e
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 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 v8.1.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 v8.1.2 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/v8.1.0/docs/api/stream.html).
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v8.1.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
8 changes: 4 additions & 4 deletions build/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ const headRegexp = /(^module.exports = \w+;?)/m
`
]
, safeBufferFix = [
/const Buffer = require\('buffer'\)\.Buffer;/,
/(?:var|const) Buffer = require\('buffer'\)\.Buffer;/,
`/*<replacement>*/
const Buffer = require('safe-buffer').Buffer
var Buffer = require('safe-buffer').Buffer
/*</replacement>*/`
]
, internalDirectory = [
Expand All @@ -177,7 +177,7 @@ const headRegexp = /(^module.exports = \w+;?)/m
, `function(er) { onwrite(stream, er); }`
]
, addUintStuff = [
/const Buffer = require\('buffer'\)\.Buffer;/
/(?:var|const) Buffer = require\('buffer'\)\.Buffer;/
, `/*<replacement>*/
const Buffer = require('safe-buffer').Buffer
function _uint8ArrayToBuffer(chunk) {
Expand Down Expand Up @@ -206,7 +206,7 @@ function WriteReq(chunk, encoding, cb) {
function CorkedRequest(state) {
this.next = null;
this.entry = null;
this.finish = onCorkedFinish.bind(undefined, this, state);
this.finish = () => { onCorkedFinish(this, state) };
}
/* </replacement> */
`
Expand Down
2 changes: 2 additions & 0 deletions lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ var EElistenerCount = function (emitter, type) {
var Stream = require('./internal/streams/stream');
/*</replacement>*/

// TODO(bmeurer): Change this back to const once hole checks are
// properly optimized away early in Ignition+TurboFan.
/*<replacement>*/
var Buffer = require('safe-buffer').Buffer;
function _uint8ArrayToBuffer(chunk) {
Expand Down
6 changes: 5 additions & 1 deletion lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ function WriteReq(chunk, encoding, cb) {
// It seems a linked list but it is not
// there will be only 2 of these for each stream
function CorkedRequest(state) {
var _this = this;

this.next = null;
this.entry = null;
this.finish = onCorkedFinish.bind(undefined, this, state);
this.finish = function () {
onCorkedFinish(_this, state);
};
}
/* </replacement> */

Expand Down
24 changes: 24 additions & 0 deletions test/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,30 @@ exports.getTTYfd = function getTTYfd() {
return tty_fd;
};

// Hijack stdout and stderr
var stdWrite = {};
function hijackStdWritable(name, listener) {
var stream = process[name];
var _write = stdWrite[name] = stream.write;

stream.writeTimes = 0;
stream.write = function (data, callback) {
listener(data);
_write.call(stream, data, callback);
stream.writeTimes++;
};
}

function restoreWritable(name) {
process[name].write = stdWrite[name];
delete process[name].writeTimes;
}

exports.hijackStdout = hijackStdWritable.bind(null, 'stdout');
exports.hijackStderr = hijackStdWritable.bind(null, 'stderr');
exports.restoreStdout = restoreWritable.bind(null, 'stdout');
exports.restoreStderr = restoreWritable.bind(null, 'stderr');

function forEach(xs, f) {
for (var i = 0, l = xs.length; i < l; i++) {
f(xs[i], i);
Expand Down

0 comments on commit cf1657e

Please sign in to comment.