diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index d0c7fcfc81b20e..6c2bbb3495a3a3 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 83cf49333a8d83..63dbc306e739f2 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(); }