• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4const { Transform, Readable, pipeline } = require('stream');
5const assert = require('assert');
6
7const reader = new Readable({
8  read(size) { this.push('foo'); }
9});
10
11let count = 0;
12
13const err = new Error('this-error-gets-hidden');
14
15const transform = new Transform({
16  transform(chunk, enc, cb) {
17    if (count++ >= 5)
18      this.emit('error', err);
19    else
20      cb(null, count.toString() + '\n');
21  }
22});
23
24pipeline(
25  reader,
26  transform,
27  process.stdout,
28  common.mustCall((e) => {
29    assert.strictEqual(e, err);
30  })
31);
32