11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst { Readable, PassThrough, pipeline } = require('stream'); 51cb0ef41Sopenharmony_ciconst assert = require('assert'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst _err = new Error('kaboom'); 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ciasync function run() { 101cb0ef41Sopenharmony_ci const source = new Readable({ 111cb0ef41Sopenharmony_ci read() { 121cb0ef41Sopenharmony_ci } 131cb0ef41Sopenharmony_ci }); 141cb0ef41Sopenharmony_ci source.push('hello'); 151cb0ef41Sopenharmony_ci source.push('world'); 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci setImmediate(() => { source.destroy(_err); }); 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_ci const iterator = pipeline( 201cb0ef41Sopenharmony_ci source, 211cb0ef41Sopenharmony_ci new PassThrough(), 221cb0ef41Sopenharmony_ci () => {}); 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ci iterator.setEncoding('utf8'); 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ci for await (const k of iterator) { 271cb0ef41Sopenharmony_ci assert.strictEqual(k, 'helloworld'); 281cb0ef41Sopenharmony_ci } 291cb0ef41Sopenharmony_ci} 301cb0ef41Sopenharmony_ci 311cb0ef41Sopenharmony_cirun().catch(common.mustCall((err) => assert.strictEqual(err, _err))); 32