Skip to content

Commit

Permalink
built 8.9.4.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed Feb 9, 2018
1 parent 56d9356 commit fa8729c
Show file tree
Hide file tree
Showing 54 changed files with 3,155 additions and 688 deletions.
58 changes: 0 additions & 58 deletions README.md
@@ -1,58 +0,0 @@
# readable-stream

***Node-core v8.1.3 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/)
[![NPM](https://nodei.co/npm-dl/readable-stream.png?&months=6&height=3)](https://nodei.co/npm/readable-stream/)


[![Sauce Test Status](https://saucelabs.com/browser-matrix/readable-stream.svg)](https://saucelabs.com/u/readable-stream)

```bash
npm install --save readable-stream
```

***Node-core streams for userland***

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.3/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).

As of version 2.0.0 **readable-stream** uses semantic versioning.

# Streams Working Group

`readable-stream` is maintained by the Streams Working Group, which
oversees the development and maintenance of the Streams API within
Node.js. The responsibilities of the Streams Working Group include:

* Addressing stream issues on the Node.js issue tracker.
* Authoring and editing stream documentation within the Node.js project.
* Reviewing changes to stream subclasses within the Node.js project.
* Redirecting changes to streams from the Node.js project to this
project.
* Assisting in the implementation of stream providers within Node.js.
* Recommending versions of `readable-stream` to be included in Node.js.
* Messaging about the future of streams to give the community advance
notice of changes.

<a name="members"></a>
## Team Members

* **Chris Dickinson** ([@chrisdickinson](https://github.com/chrisdickinson)) &lt;christopher.s.dickinson@gmail.com&gt;
- Release GPG key: 9554F04D7259F04124DE6B476D5A82AC7E37093B
* **Calvin Metcalf** ([@calvinmetcalf](https://github.com/calvinmetcalf)) &lt;calvin.metcalf@gmail.com&gt;
- Release GPG key: F3EF5F62A87FC27A22E643F714CE4FF5015AA242
* **Rod Vagg** ([@rvagg](https://github.com/rvagg)) &lt;rod@vagg.org&gt;
- Release GPG key: DD8F2338BAE7501E3DD5AC78C273792F7D83545D
* **Sam Newman** ([@sonewman](https://github.com/sonewman)) &lt;newmansam@outlook.com&gt;
* **Mathias Buus** ([@mafintosh](https://github.com/mafintosh)) &lt;mathiasbuus@gmail.com&gt;
* **Domenic Denicola** ([@domenic](https://github.com/domenic)) &lt;d@domenic.me&gt;
* **Matteo Collina** ([@mcollina](https://github.com/mcollina)) &lt;matteo.collina@gmail.com&gt;
- Release GPG key: 3ABC01543F22DD2239285CDD818674489FBC127E
* **Irina Shestak** ([@lrlna](https://github.com/lrlna)) &lt;shestak.irina@gmail.com&gt;
58 changes: 38 additions & 20 deletions build/build.js
Expand Up @@ -56,21 +56,30 @@ function processFile (inputLoc, out, replacements) {
data = data.replace(regexp, arg2)
})
if (inputLoc.slice(-3) === '.js') {
const transformed = babel.transform(data, {
plugins: [
'transform-es2015-parameters',
'transform-es2015-arrow-functions',
'transform-es2015-block-scoping',
'transform-es2015-template-literals',
'transform-es2015-shorthand-properties',
'transform-es2015-for-of',
['transform-es2015-classes', { loose: true }],
'transform-es2015-destructuring',
'transform-es2015-computed-properties',
'transform-es2015-spread'
]
})
data = transformed.code
try {
const transformed = babel.transform(data, {
plugins: [
'transform-es2015-parameters',
'transform-es2015-arrow-functions',
'transform-es2015-block-scoping',
'transform-es2015-template-literals',
'transform-es2015-shorthand-properties',
'transform-es2015-for-of',
['transform-es2015-classes', { loose: true }],
'transform-es2015-destructuring',
'transform-es2015-computed-properties',
'transform-es2015-spread'
]
})
data = transformed.code
} catch (err) {
fs.writeFile(out + '.errored.js', data, encoding, function () {
console.log('Wrote errored', out)

throw err
})
return
}
}
fs.writeFile(out, data, encoding, function (err) {
if (err) throw err
Expand Down Expand Up @@ -150,11 +159,20 @@ pump(
//--------------------------------------------------------------------
// Grab the nodejs/node test/common.js

processFile(
testsrcurl.replace(/parallel\/$/, 'common/index.js')
, path.join(testourroot, '../common.js')
, testReplace['common.js']
)
glob(path.join(src, 'test/common/*'), function (err, list) {
if (err) {
throw err
}

list.forEach(function (file) {
file = path.basename(file)
processFile(
path.join(testsrcurl.replace(/parallel\/$/, 'common/'), file)
, path.join(testourroot.replace('parallel', 'common'), file)
, testReplace['common.js']
)
})
})

//--------------------------------------------------------------------
// Update Node version in README
Expand Down
2 changes: 1 addition & 1 deletion build/common-replacements.js
Expand Up @@ -8,7 +8,7 @@ module.exports.altForEachImplReplacement = [
]

module.exports.altForEachUseReplacement = [
/(\W)([\w\.\(\),\[\]]+)(\.forEach\()/gm
/(\W)([\w\.\(\),\[\] ']+)(\.forEach\()/gm
, '$1forEach($2, '
]

Expand Down
14 changes: 8 additions & 6 deletions build/files.js
Expand Up @@ -159,10 +159,11 @@ const headRegexp = /(^module.exports = \w+;?)/m
`
]
, safeBufferFix = [
/(?:var|const) Buffer = require\('buffer'\)\.Buffer;/,
/(?:var|const) (?:{ )Buffer(?: }) = require\('buffer'\)(?:\.Buffer)?;/,
`/*<replacement>*/
var Buffer = require('safe-buffer').Buffer
/*</replacement>*/`
var Buffer = require('safe-buffer').Buffer;
/*</replacement>*/
`
]
, internalDirectory = [
/require\('internal\/streams\/([a-zA-z]+)'\)/g,
Expand All @@ -177,8 +178,8 @@ const headRegexp = /(^module.exports = \w+;?)/m
, `function(er) { onwrite(stream, er); }`
]
, addUintStuff = [
/(?:var|const) Buffer = require\('buffer'\)\.Buffer;/
, `/*<replacement>*/
/(?:var|const) Buffer = require\('safe-buffer'\)\.Buffer;/
, `
const Buffer = require('safe-buffer').Buffer
const OurUint8Array = global.Uint8Array || function () {}
function _uint8ArrayToBuffer(chunk) {
Expand All @@ -187,7 +188,6 @@ function _uint8ArrayToBuffer(chunk) {
function _isUint8Array(obj) {
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
}
/*</replacement>*/
`
]
, addConstructors = [
Expand Down Expand Up @@ -276,6 +276,7 @@ module.exports['_stream_readable.js'] = [
, processNextTickReplacement
, eventEmittterListenerCountReplacement
, internalDirectory
, safeBufferFix
, fixUintStuff
, addUintStuff
]
Expand Down Expand Up @@ -310,6 +311,7 @@ module.exports['_stream_writable.js'] = [
, fixInstanceCheck
, removeOnWriteBind
, internalDirectory
, safeBufferFix
, fixUintStuff
, addUintStuff
, fixBufferCheck
Expand Down
14 changes: 7 additions & 7 deletions build/package.json
Expand Up @@ -4,9 +4,9 @@
"description": "",
"main": "build.js",
"dependencies": {
"babel-core": "^6.24.1",
"babel-core": "^6.26.0",
"babel-plugin-transform-es2015-arrow-functions": "^6.5.2",
"babel-plugin-transform-es2015-block-scoping": "^6.24.1",
"babel-plugin-transform-es2015-block-scoping": "^6.26.0",
"babel-plugin-transform-es2015-classes": "^6.24.1",
"babel-plugin-transform-es2015-computed-properties": "^6.24.1",
"babel-plugin-transform-es2015-destructuring": "^6.18.0",
Expand All @@ -17,10 +17,10 @@
"babel-plugin-transform-es2015-template-literals": "^6.8.0",
"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.2"
"gunzip-maybe": "^1.4.1",
"hyperquest": "^2.1.3",
"pump": "^3.0.0",
"rimraf": "^2.6.2",
"tar-fs": "^1.16.0"
}
}
11 changes: 8 additions & 3 deletions build/test-replacements.js
Expand Up @@ -161,7 +161,7 @@ module.exports['common.js'] = [
],
[
/require\(['"]stream['"]\)/g
, 'require(\'../\')'
, 'require(\'../../\')'
],
[
/^var util = require\('util'\);/m
Expand Down Expand Up @@ -194,8 +194,13 @@ module.exports['common.js'] = [
'}).enable();*/'
],
[
/const async_wrap = process.binding\('async_wrap'\);/,
'//const async_wrap = process.binding(\'async_wrap\');'
/const async_wrap = process\.binding\('async_wrap'\);\n.*var kCheck = async_wrap\.constants\.kCheck;/gm,
'// const async_wrap = process.binding(\'async_wrap\');' +
' // var kCheck = async_wrap.constants.kCheck;'
],
[
/async_wrap\.async_hook_fields\[kCheck\] \+= 1;/,
'// async_wrap.async_hook_fields[kCheck] += 1;'
]
]

Expand Down
48 changes: 28 additions & 20 deletions lib/_stream_readable.js
Expand Up @@ -50,9 +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;
var OurUint8Array = global.Uint8Array || function () {};
function _uint8ArrayToBuffer(chunk) {
Expand All @@ -61,6 +60,7 @@ function _uint8ArrayToBuffer(chunk) {
function _isUint8Array(obj) {
return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
}

/*</replacement>*/

/*<replacement>*/
Expand Down Expand Up @@ -89,33 +89,40 @@ var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
function prependListener(emitter, event, fn) {
// Sadly this is not cacheable as some libraries bundle their own
// event emitter implementation with them.
if (typeof emitter.prependListener === 'function') {
return emitter.prependListener(event, fn);
} else {
// This is a hack to make sure that our error handler is attached before any
// userland ones. NEVER DO THIS. This is here only because this code needs
// to continue to work with older versions of Node.js that do not include
// the prependListener() method. The goal is to eventually remove this hack.
if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
}
if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);

// This is a hack to make sure that our error handler is attached before any
// userland ones. NEVER DO THIS. This is here only because this code needs
// to continue to work with older versions of Node.js that do not include
// the prependListener() method. The goal is to eventually remove this hack.
if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
}

function ReadableState(options, stream) {
Duplex = Duplex || require('./_stream_duplex');

options = options || {};

// Duplex streams are both readable and writable, but share
// the same options object.
// However, some cases require setting options to different
// values for the readable and the writable sides of the duplex stream.
// These options can be provided separately as readableXXX and writableXXX.
var isDuplex = stream instanceof Duplex;

// object stream flag. Used to make read(n) ignore n and to
// make all the buffer merging and length checks go away
this.objectMode = !!options.objectMode;

if (stream instanceof Duplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;

// the point at which it stops calling _read() to fill the buffer
// Note: 0 is a valid value, means "don't call _read preemptively ever"
var hwm = options.highWaterMark;
var readableHwm = options.readableHighWaterMark;
var defaultHwm = this.objectMode ? 16 : 16 * 1024;
this.highWaterMark = hwm || hwm === 0 ? hwm : defaultHwm;

if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;

// cast to ints.
this.highWaterMark = Math.floor(this.highWaterMark);
Expand Down Expand Up @@ -810,18 +817,19 @@ function flow(stream) {
// This is *not* part of the readable stream interface.
// It is an ugly unfortunate mess of history.
Readable.prototype.wrap = function (stream) {
var _this = this;

var state = this._readableState;
var paused = false;

var self = this;
stream.on('end', function () {
debug('wrapped end');
if (state.decoder && !state.ended) {
var chunk = state.decoder.end();
if (chunk && chunk.length) self.push(chunk);
if (chunk && chunk.length) _this.push(chunk);
}

self.push(null);
_this.push(null);
});

stream.on('data', function (chunk) {
Expand All @@ -831,7 +839,7 @@ Readable.prototype.wrap = function (stream) {
// don't skip over falsy values in objectMode
if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;

var ret = self.push(chunk);
var ret = _this.push(chunk);
if (!ret) {
paused = true;
stream.pause();
Expand All @@ -852,20 +860,20 @@ Readable.prototype.wrap = function (stream) {

// proxy certain important events.
for (var n = 0; n < kProxyEvents.length; n++) {
stream.on(kProxyEvents[n], self.emit.bind(self, kProxyEvents[n]));
stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
}

// when we try to consume some more bytes, simply unpause the
// underlying stream.
self._read = function (n) {
this._read = function (n) {
debug('wrapped _read', n);
if (paused) {
paused = false;
stream.resume();
}
};

return self;
return this;
};

// exposed for testing purposes only.
Expand Down

0 comments on commit fa8729c

Please sign in to comment.