Skip to content

Commit

Permalink
Build for node 8.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinmetcalf committed Jun 19, 2017
1 parent 8ba3a42 commit 98296bb
Show file tree
Hide file tree
Showing 83 changed files with 3,474 additions and 374 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 v7.0.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.0 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/v7.10.0/docs/api/stream.html).
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v8.1.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
12 changes: 7 additions & 5 deletions build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const hyperquest = require('hyperquest')
, nodeVersionRegexString = '\\d+\\.\\d+\\.\\d+'
, usageVersionRegex = RegExp('^' + nodeVersionRegexString + '$')
, readmeVersionRegex =
RegExp('((?:Node-core )|(?:https\:\/\/nodejs\.org\/dist\/)v)' + nodeVersionRegexString, 'g')
RegExp('((?:(?:Node-core )|(?:https\:\/\/nodejs\.org\/dist\/))v)' + nodeVersionRegexString, 'g')

, readmePath = path.join(__dirname, '..', 'README.md')
, files = require('./files')
Expand Down Expand Up @@ -61,7 +61,9 @@ function processFile (inputLoc, out, replacements) {
'transform-es2015-shorthand-properties',
'transform-es2015-for-of',
'transform-es2015-classes',
'transform-es2015-destructuring'
'transform-es2015-destructuring',
'transform-es2015-computed-properties',
'transform-es2015-spread'
]
})
data = transformed.code
Expand Down Expand Up @@ -134,7 +136,8 @@ pump(
file !== 'test-stream2-httpclient-response-end.js' &&
file !== 'test-stream-base-no-abort.js' &&
file !== 'test-stream-preprocess.js' &&
file !== 'test-stream-inheritance.js') {
file !== 'test-stream-inheritance.js' &&
file !== 'test-stream-base-typechecking.js') {
processTestFile(file)
}
})
Expand All @@ -145,14 +148,13 @@ pump(
// Grab the nodejs/node test/common.js

processFile(
testsrcurl.replace(/parallel\/$/, 'common.js')
testsrcurl.replace(/parallel\/$/, 'common/index.js')
, path.join(testourroot, '../common.js')
, testReplace['common.js']
)

//--------------------------------------------------------------------
// Update Node version in README

processFile(readmePath, readmePath, [
[readmeVersionRegex, "$1" + nodeVersion]
])
Expand Down
5 changes: 5 additions & 0 deletions build/common-replacements.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ module.exports.altForEachUseReplacement = [
, '$1forEach($2, '
]

module.exports.specialForEachReplacment = [
/(\W)(\[(?:\d\,\s)+\d\])(\.forEach\()/gm
, '$1forEach($2, '
]

module.exports.altIndexOfImplReplacement = [
/$/
, '\nfunction indexOf (xs, x) {\n'
Expand Down
58 changes: 39 additions & 19 deletions build/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const headRegexp = /(^module.exports = \w+;?)/m
]

, processNextTickImport = [
headRegexp
/^('use strict';)$/m
, `$1
/*<replacement>*/
Expand Down Expand Up @@ -166,8 +166,8 @@ const headRegexp = /(^module.exports = \w+;?)/m
/*</replacement>*/`
]
, internalDirectory = [
/require\('internal\/streams\/BufferList'\)/,
'require(\'./internal/streams/BufferList\')'
/require\('internal\/streams\/([a-zA-z]+)'\)/g,
'require(\'./internal/streams/$1\')'
]
, fixInstanceCheck = [
/if \(typeof Symbol === 'function' && Symbol\.hasInstance\) \{/,
Expand All @@ -177,20 +177,32 @@ const headRegexp = /(^module.exports = \w+;?)/m
/onwrite\.bind\([^)]+?\)/,
`function(er) { onwrite(stream, er); }`
]
, removeCorkedFinishBind = [
/onCorkedFinish\.bind\([^)]+?\)/,
function (match) {
const code = this
var src = /^function onCorkedFinish[^{]*?\{([\s\S]+?\r?\n)\}/m.exec(code)
src = src[1].trim().replace(/corkReq/g, 'this').replace(/(\r?\n)/mg, ' $1')
return `(err) => {\n${src}\n}`
}
, addUintStuff = [
/const Buffer = require\('buffer'\)\.Buffer;/,
`/*<replacement>*/
const Buffer = require('safe-buffer').Buffer
function _uint8ArrayToBuffer(chunk) {
return Buffer.from(chunk);
}
function _isUint8Array(obj) {
return Object.prototype.toString.call(obj) === '[object Uint8Array]' || Buffer.isBuffer(obj);
}
/*</replacement>*/
`
]
, removeOnCorkedFinish = [
/^function onCorkedFinish[\s\S]+?\r?\n\}/m,
''
, fixUintStuff = [
/Stream\.(_isUint8Array|_uint8ArrayToBuffer)\(/g,
`$1(`
]
, fixBufferCheck = [
/Object\.getPrototypeOf\((chunk)\) !== Buffer\.prototype/g,
'!Buffer.isBuffer($1)'
]
, fixCopyBuffer = [
/Buffer\.prototype\.copy\.call\(src, target, offset\);/,
'src.copy(target, offset);'
]

module.exports['_stream_duplex.js'] = [
requireReplacement
, instanceofReplacement
Expand Down Expand Up @@ -233,8 +245,9 @@ module.exports['_stream_readable.js'] = [
, processNextTickImport
, processNextTickReplacement
, eventEmittterListenerCountReplacement
, safeBufferFix
, internalDirectory
, fixUintStuff
, addUintStuff
]

module.exports['_stream_transform.js'] = [
Expand Down Expand Up @@ -264,12 +277,19 @@ module.exports['_stream_writable.js'] = [
, processNextTickReplacement
, internalUtilReplacement
, fixSyncWrite
, safeBufferFix
, fixInstanceCheck
, removeOnWriteBind
, removeCorkedFinishBind
, removeOnCorkedFinish
, internalDirectory
, fixUintStuff
, addUintStuff
, fixBufferCheck
]
module.exports['internal/streams/BufferList.js'] = [
safeBufferFix
, fixCopyBuffer

]
module.exports['internal/streams/destroy.js'] = [
processNextTickImport
, processNextTickReplacement
]
2 changes: 2 additions & 0 deletions build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
"babel-plugin-transform-es2015-arrow-functions": "^6.5.2",
"babel-plugin-transform-es2015-block-scoping": "^6.24.1",
"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",
"babel-plugin-transform-es2015-for-of": "^6.8.0",
"babel-plugin-transform-es2015-parameters": "^6.24.1",
"babel-plugin-transform-es2015-shorthand-properties": "^6.24.1",
"babel-plugin-transform-es2015-spread": "^6.22.0",
"babel-plugin-transform-es2015-template-literals": "^6.8.0",
"bl": "^1.2.1",
"glob": "^7.1.2",
Expand Down
16 changes: 15 additions & 1 deletion build/test-replacements.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const altForEachImplReplacement = require('./common-replacements').altForEachImp
require('./common-replacements').bufferShimFix
, bufferStaticMethods =
require('./common-replacements').bufferStaticMethods
, specialForEachReplacment =
require('./common-replacements').specialForEachReplacment

module.exports.all = [
[
Expand Down Expand Up @@ -44,7 +46,7 @@ module.exports.all = [

module.exports['test-stream2-basic.js'] = [
altForEachImplReplacement
, altForEachUseReplacement
, specialForEachReplacment
]

module.exports['test-stream2-objects.js'] = [
Expand Down Expand Up @@ -182,6 +184,18 @@ module.exports['common.js'] = [
[
/exports\.buildType/,
'//exports.buildType'
],
[
/require\('async_hooks'\)/,
'/*require(\'async_hooks\')'
],
[
/\}\).enable\(\);/,
'}).enable();*/'
],
[
/const async_wrap = process.binding\('async_wrap'\);/,
'//const async_wrap = process.binding(\'async_wrap\');'
]
]

Expand Down
57 changes: 53 additions & 4 deletions lib/_stream_duplex.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

// a duplex stream is just a stream that is both readable and writable.
// Since JS doesn't have multiple prototypal inheritance, this class
// prototypally inherits from Readable, and then parasitically from
Expand All @@ -7,6 +28,10 @@

/*<replacement>*/

var processNextTick = require('process-nextick-args');
/*</replacement>*/

/*<replacement>*/
var objectKeys = Object.keys || function (obj) {
var keys = [];
for (var key in obj) {
Expand All @@ -17,10 +42,6 @@ var objectKeys = Object.keys || function (obj) {

module.exports = Duplex;

/*<replacement>*/
var processNextTick = require('process-nextick-args');
/*</replacement>*/

/*<replacement>*/
var util = require('core-util-is');
util.inherits = require('inherits');
Expand Down Expand Up @@ -68,6 +89,34 @@ function onEndNT(self) {
self.end();
}

Object.defineProperty(Duplex.prototype, 'destroyed', {
get: function () {
if (this._readableState === undefined || this._writableState === undefined) {
return false;
}
return this._readableState.destroyed && this._writableState.destroyed;
},
set: function (value) {
// we ignore the value if the stream
// has not been initialized yet
if (this._readableState === undefined || this._writableState === undefined) {
return;
}

// backward compatibility, the user is explicitly
// managing destroyed
this._readableState.destroyed = value;
this._writableState.destroyed = value;
}
});

Duplex.prototype._destroy = function (err, cb) {
this.push(null);
this.end();

processNextTick(cb, err);
};

function forEach(xs, f) {
for (var i = 0, l = xs.length; i < l; i++) {
f(xs[i], i);
Expand Down
21 changes: 21 additions & 0 deletions lib/_stream_passthrough.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

// a passthrough stream.
// basically just the most minimal sort of Transform stream.
// Every written chunk gets output as-is.
Expand Down
Loading

0 comments on commit 98296bb

Please sign in to comment.