stream-to-array

WebJar for stream-to-array

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

stream-to-array
Last Version

Last Version

2.3.0
Release Date

Release Date

Type

Type

jar
Description

Description

stream-to-array
WebJar for stream-to-array
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/stream-utils/stream-to-array

Download stream-to-array

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/stream-to-array/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>stream-to-array</artifactId>
    <version>2.3.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/stream-to-array/
implementation 'org.webjars.npm:stream-to-array:2.3.0'
// https://jarcasting.com/artifacts/org.webjars.npm/stream-to-array/
implementation ("org.webjars.npm:stream-to-array:2.3.0")
'org.webjars.npm:stream-to-array:jar:2.3.0'
<dependency org="org.webjars.npm" name="stream-to-array" rev="2.3.0">
  <artifact name="stream-to-array" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='stream-to-array', version='2.3.0')
)
libraryDependencies += "org.webjars.npm" % "stream-to-array" % "2.3.0"
[org.webjars.npm/stream-to-array "2.3.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : any-promise jar [1.1.0,2)

Project Modules

There are no modules declared in this project.

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) {
    const buffers = parts
      .map(part => util.isBuffer(part) ? part : Buffer.from(part));
    return Buffer.concat(buffers);
  })
org.webjars.npm

Versions

Version
2.3.0