• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4const { Readable, PassThrough, pipeline } = require('stream');
5const assert = require('assert');
6
7const _err = new Error('kaboom');
8
9async function run() {
10  const source = new Readable({
11    read() {
12    }
13  });
14  source.push('hello');
15  source.push('world');
16
17  setImmediate(() => { source.destroy(_err); });
18
19  const iterator = pipeline(
20    source,
21    new PassThrough(),
22    () => {});
23
24  iterator.setEncoding('utf8');
25
26  for await (const k of iterator) {
27    assert.strictEqual(k, 'helloworld');
28  }
29}
30
31run().catch(common.mustCall((err) => assert.strictEqual(err, _err)));
32