mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
streams2: Emit pause/resume events
This commit is contained in:
1 parent
8fe7b0c910
commit
04541cf7bc
1 file changed
+4
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user