0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-stream-pipe-needDrain.js
Matteo Collina f8b9831338 stream: do not use _stream_* anymore
Remove all leftover usage of _stream_* and keep all of them as legacy.
We do not deprecate the old modules to avoid disrupition and ease
maintainance.

PR-URL: https://github.com/nodejs/node/pull/36684
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2021-01-05 19:02:04 +01:00

32 lines
594 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const { Readable, Writable } = require('stream');
// Pipe should pause temporarily if writable needs drain.
{
const w = new Writable({
write(buf, encoding, callback) {
process.nextTick(callback);
},
highWaterMark: 1
});
while (w.write('asd'));
assert.strictEqual(w.writableNeedDrain, true);
const r = new Readable({
read() {
this.push('asd');
this.push(null);
}
});
r.on('pause', common.mustCall(2));
r.on('end', common.mustCall());
r.pipe(w);
}