2020-09-25 18:40:01 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
const assert = require('assert');
|
2020-12-29 15:20:41 +01:00
|
|
|
const { Readable, Writable } = require('stream');
|
2020-09-25 18:40:01 +02:00
|
|
|
|
2020-12-18 12:14:30 +01:00
|
|
|
// Pipe should pause temporarily if writable needs drain.
|
2020-09-25 18:40:01 +02:00
|
|
|
{
|
|
|
|
const w = new Writable({
|
|
|
|
write(buf, encoding, callback) {
|
2020-12-18 12:14:30 +01:00
|
|
|
process.nextTick(callback);
|
|
|
|
},
|
|
|
|
highWaterMark: 1
|
2020-09-25 18:40:01 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
while (w.write('asd'));
|
|
|
|
|
|
|
|
assert.strictEqual(w.writableNeedDrain, true);
|
|
|
|
|
|
|
|
const r = new Readable({
|
|
|
|
read() {
|
|
|
|
this.push('asd');
|
2020-12-18 12:14:30 +01:00
|
|
|
this.push(null);
|
2020-09-25 18:40:01 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-12-18 12:14:30 +01:00
|
|
|
r.on('pause', common.mustCall(2));
|
|
|
|
r.on('end', common.mustCall());
|
2020-09-25 18:40:01 +02:00
|
|
|
|
|
|
|
r.pipe(w);
|
|
|
|
}
|