11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst common = require('../common'); 41cb0ef41Sopenharmony_ciconst { Transform, Readable, pipeline } = require('stream'); 51cb0ef41Sopenharmony_ciconst assert = require('assert'); 61cb0ef41Sopenharmony_ci 71cb0ef41Sopenharmony_ciconst reader = new Readable({ 81cb0ef41Sopenharmony_ci read(size) { this.push('foo'); } 91cb0ef41Sopenharmony_ci}); 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_cilet count = 0; 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ciconst err = new Error('this-error-gets-hidden'); 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ciconst transform = new Transform({ 161cb0ef41Sopenharmony_ci transform(chunk, enc, cb) { 171cb0ef41Sopenharmony_ci if (count++ >= 5) 181cb0ef41Sopenharmony_ci this.emit('error', err); 191cb0ef41Sopenharmony_ci else 201cb0ef41Sopenharmony_ci cb(null, count.toString() + '\n'); 211cb0ef41Sopenharmony_ci } 221cb0ef41Sopenharmony_ci}); 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_cipipeline( 251cb0ef41Sopenharmony_ci reader, 261cb0ef41Sopenharmony_ci transform, 271cb0ef41Sopenharmony_ci process.stdout, 281cb0ef41Sopenharmony_ci common.mustCall((e) => { 291cb0ef41Sopenharmony_ci assert.strictEqual(e, err); 301cb0ef41Sopenharmony_ci }) 311cb0ef41Sopenharmony_ci); 32