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-renderer@cambrianprotocol/clijdbc_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-rustreamer@isneezy/strapi-blurred-image-format@hacksawstudios/gitlab-ci-releaser@agrarium/cli@agrarium/preset-bem-react@educandu/educandu@edgarai/strapi-plugin-upload@adobe/helix-ops@akemona-org/strapi-plugin-upload@akashnetwork/lfs@ajuvercr/js-runner@compass-marketing/puppet-stream@coreycollins/nightcrawlerstream-to-promisestream-to-promise2sqlgridstrapi-provider-upload-multiple-providersstrapi-plugin-uploadstrapi-upload-pluginsftp-to-s3tysapi-plugin-transcodertysapi-plugin-uploadtilelive-tapalcatltlprttoner-html-to-xlsxtoner-phantom
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