diff options
author | Mikeal Rogers <mikeal.rogers@gmail.com> | 2010-07-13 17:17:05 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2010-07-13 17:17:20 -0700 |
commit | 16cb45103f29a46fbd19eb19e3042678800e1b70 (patch) | |
tree | d8db12d9257bdb3b7e54118fb1840bcbb5539fab /lib/sys.js | |
parent | 2085909aebcf47e6a6aa9c5d10cf6a960544eeec (diff) | |
download | nodejs-16cb45103f29a46fbd19eb19e3042678800e1b70.tar.gz nodejs-16cb45103f29a46fbd19eb19e3042678800e1b70.tar.bz2 nodejs-16cb45103f29a46fbd19eb19e3042678800e1b70.zip |
Adds "pause" and "resume" events to pump and it's readable argument.
Diffstat (limited to 'lib/sys.js')
-rw-r--r-- | lib/sys.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/sys.js b/lib/sys.js index ac8b023c4..867b5a9e0 100644 --- a/lib/sys.js +++ b/lib/sys.js @@ -284,14 +284,25 @@ exports.exec = function () { exports.pump = function (readStream, writeStream, callback) { + if (!readStream.pause) readStream.pause = function () {readStream.emit("pause")}; + if (!readStream.resume) readStream.resume = function () {readStream.emit("resume")}; + readStream.addListener("data", function (chunk) { if (writeStream.write(chunk) === false) readStream.pause(); }); + writeStream.addListener("pause", function () { + readStream.pause(); + }); + writeStream.addListener("drain", function () { readStream.resume(); }); + writeStream.addListener("resume", function () { + readStream.resume(); + }); + readStream.addListener("end", function () { writeStream.end(); }); |