Skip to content

Commit 9768c24

Browse files
committed
stream: readable.off
We have special logic in removeListener() which must apply to off() as well.
1 parent 17d87d5 commit 9768c24

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

lib/_stream_readable.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,7 @@ Readable.prototype.removeListener = function(ev, fn) {
914914

915915
return res;
916916
};
917+
Readable.prototype.off = Readable.prototype.removeListener;
917918

918919
Readable.prototype.removeAllListeners = function(ev) {
919920
const res = Stream.prototype.removeAllListeners.apply(this, arguments);

test/parallel/test-stream-readable-readable-then-resume.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const common = require('../common');
44
const { Readable } = require('stream');
5+
const assert = require('assert');
56

67
// This test verifies that a stream could be resumed after
78
// removing the readable event in the same tick
@@ -24,6 +25,7 @@ function check(s) {
2425
const readableListener = common.mustNotCall();
2526
s.on('readable', readableListener);
2627
s.on('end', common.mustCall());
28+
assert.strictEqual(s.removeListener, s.off);
2729
s.removeListener('readable', readableListener);
2830
s.resume();
2931
}

0 commit comments

Comments
 (0)