/ archiveofbelonging.org / back / node_modules / stream-to-array /

[ICO]NameLast modifiedSizeDescription
[PARENTDIR]Parent Directory  -  
[TXT]README.md9 years ago2.4Kf12eb36 documentaiton updates [كارل مبارك]
[   ]package.json2 years ago1.8K7375cab EXHIBTION: fix overflow ellipsis cutoff [كارل مبارك]
[   ]index.js9 years ago1.2K 
[   ]LICENSE9 years ago1.1K7375cab EXHIBTION: fix overflow ellipsis cutoff [كارل مبارك]
README.md

Stream to Array

NPM version Build status Test coverage Dependency Status License Downloads

Concatenate a readable stream's data into a single array.

You may also be interested in:

API

var toArray = require('stream-to-array')

toArray([stream], [callback(err, arr)])

Returns all the data objects in an array. This is useful for streams in object mode if you want to just use an array.

var stream = new Stream.Readable()
toArray(stream, function (err, arr) {
  assert.ok(Array.isArray(arr))
})

If stream is not defined, it is assumed that this is a stream.

var stream = new Stream.Readable()
stream.toArray = toArray
stream.toArray(function (err, arr) {

})

If callback is not defined, then it returns a promise.

toArray(stream)
  .then(function (parts) {

  })

If you want to return a buffer, just use Buffer.concat(arr)

toArray(stream)
  .then(function (parts) {
    var buffers = []
    for (var i = 0, l = parts.length; i < l ; ++i) {
      var part = parts[i]
      buffers.push((part instanceof Buffer) ? part : new Buffer(part))
    }
    return Buffer.concat(buffers)
  })
Apache/2.4.38 (Debian) Server at www.karls.computer Port 80