• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4
5// This test ensures that Readable stream will continue to call _read
6// for streams with highWaterMark === 0 once the stream returns data
7// by calling push() asynchronously.
8
9const { Readable } = require('stream');
10
11let count = 5;
12
13const r = new Readable({
14  // Called 6 times: First 5 return data, last one signals end of stream.
15  read: common.mustCall(() => {
16    process.nextTick(common.mustCall(() => {
17      if (count--)
18        r.push('a');
19      else
20        r.push(null);
21    }));
22  }, 6),
23  highWaterMark: 0,
24});
25
26r.on('end', common.mustCall());
27r.on('data', common.mustCall(5));
28