Skip to content

Commit cf1657e

Browse files
committed
Import from Node 8.1.2.
1 parent a7f526f commit cf1657e

File tree

5 files changed

+37
-7
lines changed

5 files changed

+37
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# readable-stream
22

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

55

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

21-
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v8.1.0/docs/api/stream.html).
21+
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v8.1.2/docs/api/stream.html).
2222

2323
If you want to guarantee a stable streams base, regardless of what version of
2424
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/files.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ const headRegexp = /(^module.exports = \w+;?)/m
159159
`
160160
]
161161
, safeBufferFix = [
162-
/const Buffer = require\('buffer'\)\.Buffer;/,
162+
/(?:var|const) Buffer = require\('buffer'\)\.Buffer;/,
163163
`/*<replacement>*/
164-
const Buffer = require('safe-buffer').Buffer
164+
var Buffer = require('safe-buffer').Buffer
165165
/*</replacement>*/`
166166
]
167167
, internalDirectory = [
@@ -177,7 +177,7 @@ const headRegexp = /(^module.exports = \w+;?)/m
177177
, `function(er) { onwrite(stream, er); }`
178178
]
179179
, addUintStuff = [
180-
/const Buffer = require\('buffer'\)\.Buffer;/
180+
/(?:var|const) Buffer = require\('buffer'\)\.Buffer;/
181181
, `/*<replacement>*/
182182
const Buffer = require('safe-buffer').Buffer
183183
function _uint8ArrayToBuffer(chunk) {
@@ -206,7 +206,7 @@ function WriteReq(chunk, encoding, cb) {
206206
function CorkedRequest(state) {
207207
this.next = null;
208208
this.entry = null;
209-
this.finish = onCorkedFinish.bind(undefined, this, state);
209+
this.finish = () => { onCorkedFinish(this, state) };
210210
}
211211
/* </replacement> */
212212
`

lib/_stream_readable.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ var EElistenerCount = function (emitter, type) {
5050
var Stream = require('./internal/streams/stream');
5151
/*</replacement>*/
5252

53+
// TODO(bmeurer): Change this back to const once hole checks are
54+
// properly optimized away early in Ignition+TurboFan.
5355
/*<replacement>*/
5456
var Buffer = require('safe-buffer').Buffer;
5557
function _uint8ArrayToBuffer(chunk) {

lib/_stream_writable.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,13 @@ function WriteReq(chunk, encoding, cb) {
4343
// It seems a linked list but it is not
4444
// there will be only 2 of these for each stream
4545
function CorkedRequest(state) {
46+
var _this = this;
47+
4648
this.next = null;
4749
this.entry = null;
48-
this.finish = onCorkedFinish.bind(undefined, this, state);
50+
this.finish = function () {
51+
onCorkedFinish(_this, state);
52+
};
4953
}
5054
/* </replacement> */
5155

test/common.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,30 @@ exports.getTTYfd = function getTTYfd() {
790790
return tty_fd;
791791
};
792792

793+
// Hijack stdout and stderr
794+
var stdWrite = {};
795+
function hijackStdWritable(name, listener) {
796+
var stream = process[name];
797+
var _write = stdWrite[name] = stream.write;
798+
799+
stream.writeTimes = 0;
800+
stream.write = function (data, callback) {
801+
listener(data);
802+
_write.call(stream, data, callback);
803+
stream.writeTimes++;
804+
};
805+
}
806+
807+
function restoreWritable(name) {
808+
process[name].write = stdWrite[name];
809+
delete process[name].writeTimes;
810+
}
811+
812+
exports.hijackStdout = hijackStdWritable.bind(null, 'stdout');
813+
exports.hijackStderr = hijackStdWritable.bind(null, 'stderr');
814+
exports.restoreStdout = restoreWritable.bind(null, 'stdout');
815+
exports.restoreStderr = restoreWritable.bind(null, 'stderr');
816+
793817
function forEach(xs, f) {
794818
for (var i = 0, l = xs.length; i < l; i++) {
795819
f(xs[i], i);

0 commit comments

Comments
 (0)