diff --git a/README.md b/README.md
index 5ef76c7bb9..b391e0c825 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# readable-stream
-***Node-core v8.1.0 streams for userland*** [](https://travis-ci.org/nodejs/readable-stream)
+***Node-core v8.1.2 streams for userland*** [](https://travis-ci.org/nodejs/readable-stream)
[](https://nodei.co/npm/readable-stream/)
@@ -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).
diff --git a/build/files.js b/build/files.js
index 883ed5b26b..81f075c70b 100644
--- a/build/files.js
+++ b/build/files.js
@@ -159,9 +159,9 @@ const headRegexp = /(^module.exports = \w+;?)/m
`
]
, safeBufferFix = [
- /const Buffer = require\('buffer'\)\.Buffer;/,
+ /(?:var|const) Buffer = require\('buffer'\)\.Buffer;/,
`/**/
- const Buffer = require('safe-buffer').Buffer
+ var Buffer = require('safe-buffer').Buffer
/**/`
]
, internalDirectory = [
@@ -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;/
, `/**/
const Buffer = require('safe-buffer').Buffer
function _uint8ArrayToBuffer(chunk) {
@@ -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) };
}
/* */
`
diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js
index 5e22c26268..2279be9f93 100644
--- a/lib/_stream_readable.js
+++ b/lib/_stream_readable.js
@@ -50,6 +50,8 @@ var EElistenerCount = function (emitter, type) {
var Stream = require('./internal/streams/stream');
/**/
+// TODO(bmeurer): Change this back to const once hole checks are
+// properly optimized away early in Ignition+TurboFan.
/**/
var Buffer = require('safe-buffer').Buffer;
function _uint8ArrayToBuffer(chunk) {
diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js
index 5aa779ac5d..a438f213dd 100644
--- a/lib/_stream_writable.js
+++ b/lib/_stream_writable.js
@@ -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);
+ };
}
/* */
diff --git a/test/common.js b/test/common.js
index 4fd2116ea2..c99fa9b97f 100644
--- a/test/common.js
+++ b/test/common.js
@@ -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);