function pipeStream(...args) {
  const src = args.shift();

  return new Promise((resolve, reject) => {
    let stream = src.on('error', reject);
    let target;

    while ((target = args.shift()) != null) {
      stream = stream.pipe(target).on('error', reject);
    }

    stream.on('finish', resolve);
    stream.on('end', resolve);
    stream.on('close', resolve);
  });
}
function pipeStream(...args) {
  const src = args.shift();

  return new Promise((resolve, reject) => {
    let stream = src.on('error', reject);
    let target;

    while ((target = args.shift()) != null) {
      stream = stream.pipe(target).on('error', reject);
    }

    stream.on('finish', resolve);
    stream.on('end', resolve);
    stream.on('close', resolve);
  });
}
function pipeStream ( ... args ) { const src = args . shift ( ) ; return new Promise ( ( resolve , reject ) => { let stream = src . on ( 'error' , reject ) ; let target ; while ( ( target = args . shift ( ) ) != null ) { stream = stream . pipe ( target ) . on ( 'error' , reject ) ; } stream . on ( 'finish' , resolve ) ; stream . on ( 'end' , resolve ) ; stream . on ( 'close' , resolve ) ; } ) ; }
Pipe a stream from one to another
Pipe a stream from one to another