lib/writearray.js
function WriteArray (options, callback) {
  var self = this

  if (!(this instanceof WriteArray)) {
    return new WriteArray(options, callback)
  }

  if (typeof options === 'function') {
    callback = options
    options = {}
  }

  options = Object.assign({}, options)
  Writable.call(self, options)

  self.array = []
  self.callback = callback

  self.on('pipe', function (src) {
    src.on('error', function (err) {
      self.callback(err)
    })
  })

  self.on('finish', function () {
    self.callback(null, self.array)
  })

  return self
}
function WriteArray (options, callback) {
  var self = this

  if (!(this instanceof WriteArray)) {
    return new WriteArray(options, callback)
  }

  if (typeof options === 'function') {
    callback = options
    options = {}
  }

  options = Object.assign({}, options)
  Writable.call(self, options)

  self.array = []
  self.callback = callback

  self.on('pipe', function (src) {
    src.on('error', function (err) {
      self.callback(err)
    })
  })

  self.on('finish', function () {
    self.callback(null, self.array)
  })

  return self
}
function WriteArray ( options , callback ) { var self = this if ( ! ( this instanceof WriteArray ) ) { return new WriteArray ( options , callback ) } if ( typeof options === 'function' ) { callback = options options = { } } options = Object . assign ( { } , options ) Writable . call ( self , options ) self . array = [ ] self . callback = callback self . on ( 'pipe' , function ( src ) { src . on ( 'error' , function ( err ) { self . callback ( err ) } ) } ) self . on ( 'finish' , function ( ) { self . callback ( null , self . array ) } ) return self }
Write stream into an Array

@constructor
@param {Object} [options] - Stream Options `{encoding, highWaterMark, decodeStrings, objectMode, ...}`
@param {Function} callback - callback function `function({Error}err, {Array}array)` called on `finish` or `error` event.
@return {Writable} A writable stream
Write stream into an Array