[Pkg-javascript-commits] [node-stream-splicer] 23/71: falsey chunk issue fixed with readable-wrap
Bastien Roucariès
rouca at moszumanska.debian.org
Fri Dec 15 09:55:48 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-stream-splicer.
commit 05bc74d659bdf2f7f7abe67a278b2279be333f42
Author: James Halliday <mail at substack.net>
Date: Sun Jun 8 22:13:59 2014 -0700
falsey chunk issue fixed with readable-wrap
---
example/{stream.js => header.js} | 0
index.js | 21 ++++++++++++++-------
package.json | 1 +
3 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/example/stream.js b/example/header.js
similarity index 100%
rename from example/stream.js
rename to example/header.js
diff --git a/index.js b/index.js
index 9ef1eda..7b9d948 100644
--- a/index.js
+++ b/index.js
@@ -1,8 +1,14 @@
var isarray = require('isarray');
var Duplex = require('readable-stream').Duplex;
+var Readable = require('readable-stream').Readable;
var Pass = require('readable-stream').PassThrough;
var inherits = require('inherits');
var isArray = require('isarray');
+var wrap = require('readable-wrap');
+
+var nextTick = typeof setImmediate !== 'undefined'
+ ? setImmediate : process.nextTick
+;
module.exports = Pipeline;
inherits(Pipeline, Duplex);
@@ -141,11 +147,12 @@ Pipeline.prototype.indexOf = function (stream) {
Pipeline.prototype._wrapStream = function (stream) {
if (typeof stream.read === 'function') return stream;
- var d = (new Duplex(this._wrapOptions)).wrap(stream);
- d._write = function (buf, enc, next) {
- stream.write(buf);
- next();
+ var w = wrap(stream, this._wrapOptions);
+ w._write = function (buf, enc, next) {
+ if (stream.write(buf) === false) {
+ stream.once('drain', next);
+ }
+ else nextTick(next);
};
- d.once('finish', function () { stream.end() });
- return d;
-}
+ return w;
+};
diff --git a/package.json b/package.json
index b3c78a4..5864e86 100644
--- a/package.json
+++ b/package.json
@@ -7,6 +7,7 @@
"inherits": "^2.0.1",
"isarray": "~0.0.1",
"readable-stream": "^1.1.13-1",
+ "readable-wrap": "^1.0.0",
"through2": "^1.0.0"
},
"devDependencies": {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-stream-splicer.git
More information about the Pkg-javascript-commits
mailing list