• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4const assert = require('assert');
5const Readable = require('_stream_readable');
6const Writable = require('_stream_writable');
7
8// Pipe should pause temporarily if writable needs drain.
9{
10  const w = new Writable({
11    write(buf, encoding, callback) {
12      process.nextTick(callback);
13    },
14    highWaterMark: 1
15  });
16
17  while (w.write('asd'));
18
19  assert.strictEqual(w.writableNeedDrain, true);
20
21  const r = new Readable({
22    read() {
23      this.push('asd');
24      this.push(null);
25    }
26  });
27
28  r.on('pause', common.mustCall(2));
29  r.on('end', common.mustCall());
30
31  r.pipe(w);
32}
33