mirror of
https://github.com/nodejs/node.git
synced 2025-04-29 06:19:07 +00:00

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>
32 lines
687 B
JavaScript
32 lines
687 B
JavaScript
'use strict';
|
|
|
|
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
|
|
|
|
check(new Readable({
|
|
objectMode: true,
|
|
highWaterMark: 1,
|
|
read() {
|
|
if (!this.first) {
|
|
this.push('hello');
|
|
this.first = true;
|
|
return;
|
|
}
|
|
|
|
this.push(null);
|
|
}
|
|
}));
|
|
|
|
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();
|
|
}
|