Get all chunks of a stream
npm install stream-chunksGet all chunks of a stream.
npm install stream-chunks --save
There are multiple functions for collecting the chunks of a stream.
All of them are async functions, and expect the stream as the first argument.
The chunks function collects all chunks and puts them in order in an array.
``javascript
import chunks from 'stream-chunks/chunks.js'
const array = await chunks(stream)
`
The concat function collects all chunks and combines them into a single Uint8Array object.
`javascript
import concat from 'stream-chunks/concat.js'
const all = await concat(stream)
`
The decode function collects all chunks, decodes them based on the given encoding, and combines them into a string.
`javascript
import decode from 'stream-chunks/decode.js'
const str = await decode(stream, 'utf8')
``