lib/concatFiles.js
/**
 * Emits the contents of files in the directory at dirPath as a continuous,
 * concatenated stream
 *
 * @param {String} dirPath
 *  The path to the directory at which to read the files
 *
 * @param {any} [delimiter]
 *  [optional] delimiter injected between files
 *
 * @returns {Object}
 *  Returns the created transform stream
 */
Emits the contents of files in the directory at dirPath as a continuous,
concatenated stream

@param {String} dirPath
The path to the directory at which to read the files

@param {any} [delimiter]
[optional] delimiter injected between files

@returns {Object}
Returns the created transform stream
Emits the contents of files in the directory at dirPath as a continuous concatenated stream @param { String } dirPath The path to the directory at which to read the files @param { any } [ delimiter ] [ optional ] delimiter injected between files @returns { Object } Returns the created transform stream
function concatFiles( dirPath, delimiter ){
  function transform( fileList, _, next ){
    if( isEmpty( fileList ) ) return next();
    const asFileStream
      = createAsFileStream();
    const delimiterString
      = toDelimiterString( delimiter );
    if( delimiterString ){
      asFileStream
        .on( 'eof', injectDelimiter.call( this, fileList, delimiterString ) );
    }
    asFileStream
      .on( 'bof', this.emit.bind( this, 'bof' ) );
    fromArray( fileList )
      .on( 'error', next )
      .pipe( apply( asyncify( path.join.bind( path, dirPath ) ) ) )
      .on( 'error', next )
      .pipe( asFileStream )
      .on( 'error', next )
      .on( 'data', this.push.bind( this ) )
      .on( 'finish', next );
  }
  return require( 'stream' ).Transform( {
    writableObjectMode: true,
    transform
  } );
}
function concatFiles ( dirPath , delimiter ) { function transform ( fileList , _ , next ) { if ( isEmpty ( fileList ) ) return next ( ) ; const asFileStream = createAsFileStream ( ) ; const delimiterString = toDelimiterString ( delimiter ) ; if ( delimiterString ) { asFileStream . on ( 'eof' , injectDelimiter . call ( this , fileList , delimiterString ) ) ; } asFileStream . on ( 'bof' , this . emit . bind ( this , 'bof' ) ) ; fromArray ( fileList ) . on ( 'error' , next ) . pipe ( apply ( asyncify ( path . join . bind ( path , dirPath ) ) ) ) . on ( 'error' , next ) . pipe ( asFileStream ) . on ( 'error' , next ) . on ( 'data' , this . push . bind ( this ) ) . on ( 'finish' , next ) ; } return require ( 'stream' ) . Transform ( { writableObjectMode : true , transform } ) ; }
Emits the contents of files in the directory at dirPath as a continuous,
 concatenated stream
Emits the contents of files in the directory at dirPath as a continuous concatenated stream