diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2011-01-01 16:41:39 -0800 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2011-01-01 16:41:39 -0800 |
commit | 8f5f213a6fdc0781dd3f0b09555f3cbda733e54f (patch) | |
tree | f261eeb176104118e9f97188174189c55888fde9 /lib/stream.js | |
parent | 1c7cd4aac34f98953b81a1af46ddda5b62f87899 (diff) | |
download | node-new-8f5f213a6fdc0781dd3f0b09555f3cbda733e54f.tar.gz |
Revert "Add optional filters to stream.pipe()"
This reverts commit 24aded078fd6838d2f21934e57c7cc8dfd7303d1.
Diffstat (limited to 'lib/stream.js')
-rw-r--r-- | lib/stream.js | 43 |
1 files changed, 2 insertions, 41 deletions
diff --git a/lib/stream.js b/lib/stream.js index e92c1bc5db..98f0c37fcb 100644 --- a/lib/stream.js +++ b/lib/stream.js @@ -7,55 +7,16 @@ function Stream() { util.inherits(Stream, events.EventEmitter); exports.Stream = Stream; -Stream.prototype.pipe = function(dest /* options, filter */) { +Stream.prototype.pipe = function(dest, options) { var source = this; - // parse arguments - var options, filter; - if (typeof arguments[1] == 'object') { - options = arguments[1]; - filter = arguments[2]; - } else { - filter = arguments[1]; - } - function ondata(chunk) { - // FIXME shouldn't need to test writable - this is working around bug. - // .writable should not change before a 'end' event is fired. if (dest.writable) { if (false === dest.write(chunk)) source.pause(); } } - if (!filter) { - source.on('data', ondata); - } else { - // - // TODO: needs tests - // - var wait = false; - var waitQueue = []; - - function done () { - wait = false; - // Drain the waitQueue - if (dest.writable && waitQueue.length) { - wait = true; - filter(waitQueue.shift(), ondata, done); - } - } - - source.on('data', function (d) { - if (wait) { - waitQueue.push(d); - source.pause(); - } else { - wait = true; - filter(d, ondata, done); - } - }); - } - + source.on('data', ondata); function ondrain() { if (source.readable) source.resume(); |