# stream-chunks

> Get all chunks of a stream

Latest version **1.0.0** (published 2022-10-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install stream-chunks
pnpm add stream-chunks
yarn add stream-chunks
bun add stream-chunks
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads; no types.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2022-10-02 |
| First published | 2022-10-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Thomas Bergwinkl |
| Maintainers | bergos |
| Keywords | array, async, buffer, chunk, readable, stream |

## Links

- npm: https://www.npmjs.com/package/stream-chunks
- Repository: https://github.com/bergos/stream-chunks
- Issues: https://github.com/bergos/stream-chunks/issues
- npm.io page: https://npm.io/package/stream-chunks

## Dependencies (2)

- [buffer](https://npm.io/package/buffer.md) ^6.0.3
- [string_decoder](https://npm.io/package/string_decoder.md) ^1.3.0

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2022-10-02

## README

# stream-chunks
[![build status](https://img.shields.io/github/workflow/status/bergos/stream-chunks/Test)](https://github.com/bergos/stream-chunks/actions/workflows/test.yaml)
[![npm version](https://img.shields.io/npm/v/stream-chunks.svg)](https://www.npmjs.com/package/stream-chunks)

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. 

```javascript
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.

```javascript
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.

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

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

---
_Source: https://npm.io/package/stream-chunks · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
