Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2011-01-02 03:41:39 +0300
committerRyan Dahl <ry@tinyclouds.org>2011-01-02 03:41:39 +0300
commit8f5f213a6fdc0781dd3f0b09555f3cbda733e54f (patch)
treef261eeb176104118e9f97188174189c55888fde9 /lib
parent1c7cd4aac34f98953b81a1af46ddda5b62f87899 (diff)
Revert "Add optional filters to stream.pipe()"
This reverts commit 24aded078fd6838d2f21934e57c7cc8dfd7303d1.
Diffstat (limited to 'lib')
-rw-r--r--lib/stream.js43
1 files changed, 2 insertions, 41 deletions
diff --git a/lib/stream.js b/lib/stream.js
index e92c1bc5dbe..98f0c37fcbc 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();