JSPM

stream-chunks

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 15031
  • Score
    100M100P100Q137873F
  • License MIT

Get all chunks of a stream

Package Exports

  • stream-chunks
  • stream-chunks/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (stream-chunks) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

stream-chunks

build status npm version

Get all chunks of a stream.

Install

npm install stream-chunks --save

Usage

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.

Raw as array

The chunks function collects all chunks and puts them in order in an array.

import chunks from 'stream-chunks/chunks.js'

const array = await chunks(stream)

Combined into an Uint8Array

The concat function collects all chunks and combines them into a single Uint8Array object.

import concat from 'stream-chunks/concat.js'

const all = await concat(stream)

Combined into a string

The decode function collects all chunks, decodes them based on the given encoding, and combines them into a string.

import decode from 'stream-chunks/decode.js'

const str = await decode(stream, 'utf8')