diff options
author | Robert Nagy <ronagy@icloud.com> | 2019-09-07 23:29:18 +0200 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-09-25 18:21:04 +0200 |
commit | 123437bcc370e21d24c367dec8705644214c39e3 (patch) | |
tree | 314891117c9ec8e9041f187dfa3fce896bc48820 | |
parent | 9150c4dc72952b84d5410874ec9cc8c8a4b3db28 (diff) | |
download | node-new-123437bcc370e21d24c367dec8705644214c39e3.tar.gz |
stream: apply special logic in removeListener for readable.off()
We have special logic in removeListener() which must apply
to off() as well.
PR-URL: https://github.com/nodejs/node/pull/29486
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
-rw-r--r-- | lib/_stream_readable.js | 1 | ||||
-rw-r--r-- | test/parallel/test-stream-readable-readable-then-resume.js | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index d0c7fcfc81..6c2bbb3495 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -908,6 +908,7 @@ Readable.prototype.removeListener = function(ev, fn) { return res; }; +Readable.prototype.off = Readable.prototype.removeListener; Readable.prototype.removeAllListeners = function(ev) { const res = Stream.prototype.removeAllListeners.apply(this, arguments); diff --git a/test/parallel/test-stream-readable-readable-then-resume.js b/test/parallel/test-stream-readable-readable-then-resume.js index 83cf49333a..63dbc306e7 100644 --- a/test/parallel/test-stream-readable-readable-then-resume.js +++ b/test/parallel/test-stream-readable-readable-then-resume.js @@ -2,6 +2,7 @@ const common = require('../common'); const { Readable } = require('stream'); +const assert = require('assert'); // This test verifies that a stream could be resumed after // removing the readable event in the same tick @@ -24,6 +25,7 @@ function check(s) { const readableListener = common.mustNotCall(); s.on('readable', readableListener); s.on('end', common.mustCall()); + assert.strictEqual(s.removeListener, s.off); s.removeListener('readable', readableListener); s.resume(); } |