Skip to content

Commit

Permalink
Built with 29 tests failing
Browse files Browse the repository at this point in the history
  • Loading branch information
mcollina committed May 22, 2018
1 parent b3cf9b1 commit e9cde33
Show file tree
Hide file tree
Showing 130 changed files with 4,155 additions and 959 deletions.
43 changes: 2 additions & 41 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,15 @@
sudo: false
language: node_js
before_install:
- npm install -g npm@2
- test $NPM_LEGACY && npm install -g npm@latest-3 || npm install npm -g
notifications:
email: false
matrix:
fast_finish: true
include:
- node_js: '0.8'
env:
- TASK=test
- NPM_LEGACY=true
- node_js: '0.10'
env:
- TASK=test
- NPM_LEGACY=true
- node_js: '0.11'
env:
- TASK=test
- NPM_LEGACY=true
- node_js: '0.12'
env:
- TASK=test
- NPM_LEGACY=true
- node_js: 1
env:
- TASK=test
- NPM_LEGACY=true
- node_js: 2
env:
- TASK=test
- NPM_LEGACY=true
- node_js: 3
env:
- TASK=test
- NPM_LEGACY=true
- node_js: 4
env: TASK=test
- node_js: 5
env: TASK=test
- node_js: 6
env: TASK=test
- node_js: 7
env: TASK=test
- node_js: 8
env: TASK=test
- node_js: 9
env: TASK=test
script: "npm run $TASK"
- node_js: 10
script: "npm test"
env:
global:
- secure: rE2Vvo7vnjabYNULNyLFxOyt98BoJexDqsiOnfiD6kLYYsiQGfr/sbZkPMOFm9qfQG7pjqx+zZWZjGSswhTt+626C0t/njXqug7Yps4c3dFblzGfreQHp7wNX5TFsvrxd6dAowVasMp61sJcRnB2w8cUzoe3RAYUDHyiHktwqMc=
Expand Down
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.11.1 streams for userland*** [![Build Status](https://travis-ci.org/nodejs/readable-stream.svg?branch=master)](https://travis-ci.org/nodejs/readable-stream)
***Node-core v10.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/v8.11.1/docs/api/stream.html).
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v10.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
9 changes: 7 additions & 2 deletions build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if (!usageVersionRegex.test(nodeVersion)) {
}

// `inputLoc`: URL or local path.
function processFile (inputLoc, out, replacements) {
function processFile (inputLoc, out, replacements, addAtEnd) {
var file = fs.createReadStream(inputLoc, encoding)

file.pipe(bl(function (err, data) {
Expand All @@ -55,6 +55,10 @@ function processFile (inputLoc, out, replacements) {
}
data = data.replace(regexp, arg2)
})

if (addAtEnd) {
data += addAtEnd
}
if (inputLoc.slice(-3) === '.js') {
try {
const transformed = babel.transform(data, {
Expand All @@ -65,6 +69,7 @@ function processFile (inputLoc, out, replacements) {
'transform-es2015-template-literals',
'transform-es2015-shorthand-properties',
'transform-es2015-for-of',
'transform-async-generator-functions',
['transform-es2015-classes', { loose: true }],
'transform-es2015-destructuring',
'transform-es2015-computed-properties',
Expand Down Expand Up @@ -113,7 +118,7 @@ function processTestFile (file) {
if (testReplace[file])
replacements = replacements.concat(testReplace[file])

processFile(url, out, replacements)
processFile(url, out, replacements, ';require(\'tap\').pass(\'sync run\');')
}

//--------------------------------------------------------------------
Expand Down
45 changes: 32 additions & 13 deletions build/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,6 @@ const headRegexp = /(^module.exports = \w+;?)/m
+ '}catch(_){}}());\n'
]

, isArrayDefine = [
headRegexp
, '$1\n\n/*<replacement>*/\nvar isArray = require(\'isarray\');\n/*</replacement>*/\n'
]

, isArrayReplacement = [
/Array\.isArray/g
, 'isArray'
]

, objectKeysDefine = require('./common-replacements').objectKeysDefine

, objectKeysReplacement = require('./common-replacements').objectKeysReplacement
Expand Down Expand Up @@ -230,6 +220,18 @@ function CorkedRequest(state) {
/Buffer\.prototype\.copy\.call\(src, target, offset\);/
, 'src.copy(target, offset);'
]
, errorsOneLevel = [
/internal\/errors/
, '../errors'
]
, errorsTwoLevel = [
/internal\/errors/
, '../../../errors'
]
, warnings = [
/^const { emitExperimentalWarning } = require\('internal\/util'\);/m,
'const { emitExperimentalWarning } = require(\'../experimentalWarning\');'
]

module.exports['_stream_duplex.js'] = [
requireReplacement
Expand All @@ -240,13 +242,15 @@ module.exports['_stream_duplex.js'] = [
, objectKeysDefine
, processNextTickImport
, processNextTickReplacement
, errorsOneLevel
]

module.exports['_stream_passthrough.js'] = [
requireReplacement
, instanceofReplacement
, utilReplacement
, stringDecoderReplacement
, errorsOneLevel
]

module.exports['_stream_readable.js'] = [
Expand All @@ -257,8 +261,6 @@ module.exports['_stream_readable.js'] = [
, altIndexOfImplReplacement
, altIndexOfUseReplacement
, stringDecoderReplacement
, isArrayReplacement
, isArrayDefine
, debugLogReplacement
, utilReplacement
, stringDecoderReplacement
Expand All @@ -272,13 +274,16 @@ module.exports['_stream_readable.js'] = [
, safeBufferFix
, fixUintStuff
, addUintStuff
, errorsOneLevel
, warnings
]

module.exports['_stream_transform.js'] = [
requireReplacement
, instanceofReplacement
, utilReplacement
, stringDecoderReplacement
, errorsOneLevel
]

module.exports['_stream_writable.js'] = [
Expand Down Expand Up @@ -311,9 +316,10 @@ module.exports['_stream_writable.js'] = [
, useWriteReq
, useCorkedRequest
, addConstructors
, errorsOneLevel
]

module.exports['internal/streams/BufferList.js'] = [
module.exports['internal/streams/buffer_list.js'] = [
[
/(?:var|const) (?:{ )Buffer(?: }) = require\('buffer'\)(?:\.Buffer)?;/,
`
Expand All @@ -339,4 +345,17 @@ if (util && util.inspect && util.inspect.custom) {
module.exports['internal/streams/destroy.js'] = [
processNextTickImport
, processNextTickReplacement
, errorsTwoLevel
]

module.exports['internal/streams/state.js'] = [
processNextTickImport
, processNextTickReplacement
, errorsTwoLevel
]

module.exports['internal/streams/async_iterator.js'] = [
processNextTickImport
, processNextTickReplacement
, errorsTwoLevel
]
9 changes: 6 additions & 3 deletions build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "build.js",
"dependencies": {
"babel-core": "^6.26.0",
"babel-core": "^6.26.3",
"babel-plugin-transform-es2015-arrow-functions": "^6.5.2",
"babel-plugin-transform-es2015-block-scoping": "^6.26.0",
"babel-plugin-transform-es2015-classes": "^6.24.1",
Expand All @@ -15,12 +15,15 @@
"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",
"bl": "^2.0.0",
"glob": "^7.1.2",
"gunzip-maybe": "^1.4.1",
"hyperquest": "^2.1.3",
"pump": "^3.0.0",
"rimraf": "^2.6.2",
"tar-fs": "^1.16.0"
"tar-fs": "^1.16.2"
},
"devDependencies": {
"babel-plugin-transform-async-generator-functions": "^6.24.1"
}
}
4 changes: 2 additions & 2 deletions build/test-replacements.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ module.exports['test-stream3-cork-uncork.js'] = module.exports['test-stream3-cor
]
module.exports['test-stream2-readable-from-list.js'] = [
[
/require\('internal\/streams\/BufferList'\)/,
'require(\'../../lib/internal/streams/BufferList\')'
/require\('internal\/streams\/buffer_list'\)/,
'require(\'../../lib/internal/streams/buffer_list\')'
]
]
module.exports['test-stream-writev.js'] = [
Expand Down
26 changes: 26 additions & 0 deletions errors.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';

const codes = {};

function createErrorType(name) {
function E(message) {
if (!Error.captureStackTrace)
this.stack = (new Error()).stack;
else
Error.captureStackTrace(this, this.constructor);
this.message = message;
}
E.prototype = new Error();
E.prototype.name = name;
E.prototype.constructor = E;

codes[name] = E;
}

createErrorType('ERR_INVALID_OPT_VALUE');
createErrorType('ERR_INVALID_ARG_TYPE');
createErrorType('ERR_STREAM_PUSH_AFTER_EOF');
createErrorType('ERR_METHOD_NOT_IMPLEMENTED');
createErrorType('ERR_STREAM_PUSH_AFTER_EOF');

module.exports.codes = codes;
13 changes: 13 additions & 0 deletions experimentalWarning.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict'

const experimentalWarnings = new Set();

function emitExperimentalWarning(feature) {
if (experimentalWarnings.has(feature)) return;
const msg = `${feature} is an experimental feature. This feature could ` +
'change at any time';
experimentalWarnings.add(feature);
process.emitWarning(msg, 'ExperimentalWarning');

This comment has been minimized.

Copy link
@jimmywarting

jimmywarting Sep 5, 2018

Contributor

In the browser process.emitWarning is undefined (not a function)

Needs feature detection.

}

module.exports.emitExperimentalWarning = emitExperimentalWarning;
55 changes: 37 additions & 18 deletions lib/_stream_duplex.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var Writable = require('./_stream_writable');
util.inherits(Duplex, Readable);

{
// avoid scope creep, the keys array can then be collected
// Allow the keys array to be GC'ed.
var keys = objectKeys(Writable.prototype);
for (var v = 0; v < keys.length; v++) {
var method = keys[v];
Expand All @@ -66,15 +66,18 @@ function Duplex(options) {

Readable.call(this, options);
Writable.call(this, options);
this.allowHalfOpen = true;

if (options && options.readable === false) this.readable = false;

if (options && options.writable === false) this.writable = false;
if (options) {
if (options.readable === false) this.readable = false;

this.allowHalfOpen = true;
if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
if (options.writable === false) this.writable = false;

this.once('end', onend);
if (options.allowHalfOpen === false) {
this.allowHalfOpen = false;
this.once('end', onend);
}
}
}

Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
Expand All @@ -87,11 +90,30 @@ Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
}
});

Object.defineProperty(Duplex.prototype, 'writableBuffer', {
// making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
enumerable: false,
get: function () {
return this._writableState && this._writableState.getBuffer();
}
});

Object.defineProperty(Duplex.prototype, 'writableLength', {
// making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
enumerable: false,
get: function () {
return this._writableState.length;
}
});

// the no-half-open enforcer
function onend() {
// if we allow half-open state, or if the writable side ended,
// then we're ok.
if (this.allowHalfOpen || this._writableState.ended) return;
// If the writable side ended, then we're ok.
if (this._writableState.ended) return;

// no more data can be written.
// But allow more writes to happen in this tick.
Expand All @@ -103,6 +125,10 @@ function onEndNT(self) {
}

Object.defineProperty(Duplex.prototype, 'destroyed', {
// making it explicit this property is not enumerable
// because otherwise some prototype manipulation in
// userland will fail
enumerable: false,
get: function () {
if (this._readableState === undefined || this._writableState === undefined) {
return false;
Expand All @@ -121,11 +147,4 @@ Object.defineProperty(Duplex.prototype, 'destroyed', {
this._readableState.destroyed = value;
this._writableState.destroyed = value;
}
});

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

pna.nextTick(cb, err);
};
});

0 comments on commit e9cde33

Please sign in to comment.