mirror of
https://github.com/nodejs/node.git
synced 2025-05-01 17:03:34 +00:00

- Remove unneeded listener for the `'error'` event. - Use `common.mustCall()`. - Verify that the `src` stream gets paused. PR-URL: https://github.com/nodejs/node/pull/36056 Refs: https://github.com/nodejs/node/pull/35941 Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Ricky Zhou <0x19951125@gmail.com>
30 lines
547 B
JavaScript
30 lines
547 B
JavaScript
'use strict';
|
|
// https://github.com/nodejs/node/issues/35926
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const stream = require('stream');
|
|
|
|
let loops = 5;
|
|
|
|
const src = new stream.Readable({
|
|
read() {
|
|
if (loops--)
|
|
this.push(Buffer.alloc(20000));
|
|
}
|
|
});
|
|
|
|
const dst = new stream.Transform({
|
|
transform(chunk, output, fn) {
|
|
this.push(null);
|
|
fn();
|
|
}
|
|
});
|
|
|
|
src.pipe(dst);
|
|
|
|
dst.on('data', () => { });
|
|
dst.on('end', common.mustCall(() => {
|
|
assert.strictEqual(loops, 3);
|
|
assert.ok(src.isPaused());
|
|
}));
|