2.3.0 • Published 10 years ago

stream-to-array v2.3.0

Weekly downloads
359,839
License
MIT
Repository
github
Last release
10 years ago

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)
  })
dotclub-admin-web-backendstrapi-plugin-upload-filepondcaoliao-plugin-uploadppppubnode-red-node-sesteksacmeddataminelab-plywoodumo-bakery@tealess/plugin-upload@infinitebrahmanuniverse/nolb-stream-@everything-registry/sub-chunk-2834plugin-release-notes-azuretapalcatlxd-thumbnail-extractortelegraph-uploaderstrapi-plugin-document-managertestlodestarswf-extractvoxa-polly-rendererjdbc_web_clientjdbcsql_web_clientjsreport-electron-pdfjsreport-import-exportjsreport-officejsreport-phantom-imagejsreport-phantom-pdfjsdtjsonogramjsgui3-serverkevhuman-sortifx-postgridimage-diff-testergulp-injectgulp-jbbgulp-jbb-profilegulp-bem-xjstgulp-gziphexo-asset-pipelinehexo-asset-revisioninghexo-cutehexo-filter-lqiphexo-filter-responsive-imageshexo-responsive-imageshexo-uncsshexo-uncss2gulp-zopfli-nodegulp-zopfligulp-zopfli-forkgulp-zopfli-greengulp-less-changedgulp-upyungulp-upyun-hotfixhexo-image-sizeshexo-imageminhexo-filter-cleanuphexo-neatlevel-pathwiselevel-mqttlets-releasemadgekite.js@x-team/strapi-plugin-upload@toanz/strapi-plugin-upload@topgames/plywood@todesktop/cli@trigo/jsdt@voilab/vmol-s3@tepez/pdf-to-pngaggregate-streamadafruit-mcp23008-ssd1306-node-driverazure-kusto-ingestassets-inject-webpack-pluginbackend-rustreamerget-csvgatsby-source-gcp-storagefuel-corefrictionless-js-browserfrictionless.jsfuse.cachefsedc-pipe-to-bufferegg-lt-framework-admindobi-cache-2dstore-jsegg-filestorees-objectsexpress-bem-xjstfg-multiple-hooksfile-isfast-gatewayflexelfms-api-clientcomponent-builder2component-search2commits-betweencobrabot-patchcmdatahub-demo-1couchifycustom-plugin-uploaddata.js
2.3.0

10 years ago

2.2.1

10 years ago

2.2.0

10 years ago

2.1.0

10 years ago

2.0.2

11 years ago

2.0.1

11 years ago

2.0.0

11 years ago

1.0.0

12 years ago