2.3.0 • Published 9 years ago

stream-to-array v2.3.0

Weekly downloads
359,839
License
MIT
Repository
github
Last release
9 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@compass-marketing/puppet-stream@coreycollins/nightcrawler@dinevillar/json-api-serializer@descco/hexo-resources@cambrianprotocol/clijdbc_web_clientjdbcsql_web_clientjsreport-electron-pdfjsreport-import-exportjsreport-officejsreport-phantom-imagejsreport-phantom-pdfjsdtjsonogramjsgui3-serverkevstream-to-promisestream-to-promise2sqlgridstrapi-provider-upload-multiple-providersstrapi-plugin-uploadstrapi-upload-pluginsftp-to-s3tysapi-plugin-transcodertysapi-plugin-uploadtilelive-tapalcatltlprttoner-html-to-xlsxtoner-phantom@andan/semantic-release-gitlab-dryrun@adobe/helix-ops@agrarium/preset-bem-react@agrarium/cli@akemona-org/strapi-plugin-upload@ajuvercr/js-runner@akashnetwork/lfs@carimus/node-disks@ceramicnetwork/cli@bem/gulpy-websockets-streaming-clientzenapi-plugin-uploadwarhead@dustil/cli@dweidenfeld/testcontainers@edgarai/strapi-plugin-upload@hacksawstudios/gitlab-ci-releaser@healthstreet/fms-api-client@hutson/semantic-delivery-gitlab@hydrofoil/knossos@finviet-jsrpt/jsrpt-electron-pdf@finviet-jsrpt/jsrpt-express@finviet-jsrpt/jsrpt-import-export@finviet-jsrpt/jsrpt-phantom-image@finviet-jsrpt/jsrpt-phantom-pdf@educandu/educandu@fuel-js/logic@fuel-js/wallet@kontakta/cloud-code-directives@kontaa/directives@khoazero123/strapi-plugin-upload@latticexyz/gas-report@luantm/strapi-plugin-upload@leptonix/webscraper@leptonix/code@leptonix/electronics@leptonix/library@leptonix/list@isneezy/strapi-blurred-image-format@lgbot/madge@mtech/semantic-delivery-gitlab@masagroup/ecore@eniromaps/tile-worker@eniromaps/tile-workers@internalfx/sqlgrid@jsreport/jsreport-express@jsreport/jsreport-import-export@rdfc/js-runner@programmerraj/create-index-js@ptsecurity/gitlab-release@sap/hana-project-explorer@petitchevalroux/dataset-stream-to-xy
2.3.0

9 years ago

2.2.1

9 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