readable-stream
Advanced tools
Comparing version 2.1.5 to 2.2.0
@@ -13,2 +13,6 @@ 'use strict'; | ||
/*<replacement>*/ | ||
var Duplex; | ||
/*</replacement>*/ | ||
Readable.ReadableState = ReadableState; | ||
@@ -61,2 +65,4 @@ | ||
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') { | ||
@@ -73,3 +79,2 @@ return emitter.prependListener(event, fn); | ||
var Duplex; | ||
function ReadableState(options, stream) { | ||
@@ -144,3 +149,2 @@ Duplex = Duplex || require('./_stream_duplex'); | ||
var Duplex; | ||
function Readable(options) { | ||
@@ -468,3 +472,3 @@ Duplex = Duplex || require('./_stream_duplex'); | ||
Readable.prototype._read = function (n) { | ||
this.emit('error', new Error('not implemented')); | ||
this.emit('error', new Error('_read() is not implemented')); | ||
}; | ||
@@ -647,4 +651,4 @@ | ||
for (var _i = 0; _i < len; _i++) { | ||
dests[_i].emit('unpipe', this); | ||
for (var i = 0; i < len; i++) { | ||
dests[i].emit('unpipe', this); | ||
}return this; | ||
@@ -654,6 +658,6 @@ } | ||
// try to find the right one. | ||
var i = indexOf(state.pipes, dest); | ||
if (i === -1) return this; | ||
var index = indexOf(state.pipes, dest); | ||
if (index === -1) return this; | ||
state.pipes.splice(i, 1); | ||
state.pipes.splice(index, 1); | ||
state.pipesCount -= 1; | ||
@@ -660,0 +664,0 @@ if (state.pipesCount === 1) state.pipes = state.pipes[0]; |
@@ -97,3 +97,2 @@ // a transform stream is a readable/writable stream where you do | ||
// when the writable side finishes, then flush out anything remaining. | ||
var stream = this; | ||
@@ -115,5 +114,6 @@ | ||
// When the writable side finishes, then flush out anything remaining. | ||
this.once('prefinish', function () { | ||
if (typeof this._flush === 'function') this._flush(function (er) { | ||
done(stream, er); | ||
if (typeof this._flush === 'function') this._flush(function (er, data) { | ||
done(stream, er, data); | ||
});else done(stream); | ||
@@ -139,3 +139,3 @@ }); | ||
Transform.prototype._transform = function (chunk, encoding, cb) { | ||
throw new Error('Not implemented'); | ||
throw new Error('_transform() is not implemented'); | ||
}; | ||
@@ -170,5 +170,7 @@ | ||
function done(stream, er) { | ||
function done(stream, er, data) { | ||
if (er) return stream.emit('error', er); | ||
if (data !== null && data !== undefined) stream.push(data); | ||
// if there's nothing in the write buffer, then that means | ||
@@ -175,0 +177,0 @@ // that nothing more will ever be provided |
@@ -17,2 +17,6 @@ // A bit simpler than readable streams. | ||
/*<replacement>*/ | ||
var Duplex; | ||
/*</replacement>*/ | ||
Writable.WritableState = WritableState; | ||
@@ -58,3 +62,2 @@ | ||
var Duplex; | ||
function WritableState(options, stream) { | ||
@@ -81,2 +84,3 @@ Duplex = Duplex || require('./_stream_duplex'); | ||
// drain event flag. | ||
this.needDrain = false; | ||
@@ -156,3 +160,3 @@ // at the start of calling end() | ||
WritableState.prototype.getBuffer = function writableStateGetBuffer() { | ||
WritableState.prototype.getBuffer = function getBuffer() { | ||
var current = this.bufferedRequest; | ||
@@ -177,10 +181,34 @@ var out = []; | ||
var Duplex; | ||
// Test _writableState for inheritance to account for Duplex streams, | ||
// whose prototype chain only points to Readable. | ||
var realHasInstance; | ||
if (typeof Symbol === 'function' && Symbol.hasInstance) { | ||
realHasInstance = Function.prototype[Symbol.hasInstance]; | ||
Object.defineProperty(Writable, Symbol.hasInstance, { | ||
value: function (object) { | ||
if (realHasInstance.call(this, object)) return true; | ||
return object && object._writableState instanceof WritableState; | ||
} | ||
}); | ||
} else { | ||
realHasInstance = function (object) { | ||
return object instanceof this; | ||
}; | ||
} | ||
function Writable(options) { | ||
Duplex = Duplex || require('./_stream_duplex'); | ||
// Writable ctor is applied to Duplexes, though they're not | ||
// instanceof Writable, they're instanceof Readable. | ||
if (!(this instanceof Writable) && !(this instanceof Duplex)) return new Writable(options); | ||
// Writable ctor is applied to Duplexes, too. | ||
// `realHasInstance` is necessary because using plain `instanceof` | ||
// would return false, as no `_writableState` property is attached. | ||
// Trying to use the custom `instanceof` for Writable here will also break the | ||
// Node.js LazyTransform implementation, which has a non-trivial getter for | ||
// `_writableState` that would lead to infinite recursion. | ||
if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) { | ||
return new Writable(options); | ||
} | ||
this._writableState = new WritableState(options, this); | ||
@@ -444,3 +472,3 @@ | ||
Writable.prototype._write = function (chunk, encoding, cb) { | ||
cb(new Error('not implemented')); | ||
cb(new Error('_write() is not implemented')); | ||
}; | ||
@@ -447,0 +475,0 @@ |
{ | ||
"name": "readable-stream", | ||
"version": "2.1.5", | ||
"version": "2.2.0", | ||
"description": "Streams3, a user-land copy of the stream library from Node.js", | ||
@@ -9,4 +9,4 @@ "main": "readable.js", | ||
"core-util-is": "~1.0.0", | ||
"isarray": "~1.0.0", | ||
"inherits": "~2.0.1", | ||
"isarray": "~1.0.0", | ||
"process-nextick-args": "~1.0.6", | ||
@@ -19,2 +19,3 @@ "string_decoder": "~0.10.x", | ||
"babel-polyfill": "^6.9.1", | ||
"buffer": "^4.9.0", | ||
"nyc": "^6.4.0", | ||
@@ -25,2 +26,9 @@ "tap": "~0.7.1", | ||
}, | ||
"bundledDependencies": [ | ||
"buffer-shims", | ||
"core-util-is", | ||
"isarray", | ||
"process-nextick-args", | ||
"util-deprecate" | ||
], | ||
"scripts": { | ||
@@ -27,0 +35,0 @@ "test": "tap test/parallel/*.js test/ours/*.js", |
# readable-stream | ||
***Node-core v6.3.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 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) | ||
@@ -19,4 +19,6 @@ | ||
This package is a mirror of the Streams2 and Streams3 implementations in | ||
Node-core, including [documentation](doc/stream.md). | ||
Node-core. | ||
Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v7.1.0/docs/api/). | ||
If you want to guarantee a stable streams base, regardless of what version of | ||
@@ -38,1 +40,3 @@ 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). | ||
* **Domenic Denicola** ([@domenic](https://github.com/domenic)) <d@domenic.me> | ||
* **Matteo Collina** ([@mcollina](https://github.com/mcollina)) <matteo.collina@gmail.com> | ||
- Release GPG key: 3ABC01543F22DD2239285CDD818674489FBC127E |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47
1958
41
114914
7