• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3const { PassThrough } = require('stream');
4
5const encode = new PassThrough({
6  highWaterMark: 1
7});
8
9const decode = new PassThrough({
10  highWaterMark: 1
11});
12
13const send = common.mustCall((buf) => {
14  encode.write(buf);
15}, 4);
16
17let i = 0;
18const onData = common.mustCall(() => {
19  if (++i === 2) {
20    send(Buffer.from([0x3]));
21    send(Buffer.from([0x4]));
22  }
23}, 4);
24
25encode.pipe(decode).on('data', onData);
26
27send(Buffer.from([0x1]));
28send(Buffer.from([0x2]));
29