From 04541cf7bccb2be9fa4e587db8cfb21392d97c2d Mon Sep 17 00:00:00 2001 From: isaacs Date: Wed, 12 Dec 2012 22:17:57 -0800 Subject: [PATCH] streams2: Emit pause/resume events --- lib/_stream_readable.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index ed65af9c2d..8c6e1b5b4f 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -524,10 +524,12 @@ Readable.prototype.addListener = Readable.prototype.on; Readable.prototype.resume = function() { emitDataEvents(this); this.read(0); + this.emit('resume'); }; Readable.prototype.pause = function() { emitDataEvents(this, true); + this.emit('pause'); }; function emitDataEvents(stream, startPaused) { @@ -561,6 +563,7 @@ function emitDataEvents(stream, startPaused) { stream.pause = function() { paused = true; + this.emit('pause'); }; stream.resume = function() { @@ -571,6 +574,7 @@ function emitDataEvents(stream, startPaused) { }); else this.read(0); + this.emit('resume'); }; // now make it start, just in case it hadn't already.