# accumulate-stream

> Transform stream that accumulates and emits data upon events

Latest version **5.0.0** (published 2021-11-07) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2021-11-07 |
| First published | 2021-01-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 10.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 302 |
| Author | Ran Cohen |
| Maintainers | rannn505 |

## Links

- npm: https://www.npmjs.com/package/accumulate-stream
- Repository: https://github.com/rannn505/child-shell
- Homepage: https://github.com/rannn505/child-shell/tree/master/packages/accumulate-stream#readme
- Issues: https://github.com/rannn505/child-shell/issues
- npm.io page: https://npm.io/package/accumulate-stream

## Dependencies (2)

- [ms](https://npm.io/package/ms.md) ^2.1.3
- [bytes](https://npm.io/package/bytes.md) ^3.1.0

## Recent versions

- 5.0.0 (latest) — 2021-11-07
- 5.0.0-next.3 (next) — 2021-01-27

## README

# `accumulate-stream`

> Transform stream that accumulates and emits data upon events

## Installation

```bash
$ npm i -S accumulate-stream
$ yarn add accumulate-stream
```

## Usage

```js
import { createReadStream } from 'fs';
import { once } from 'events';
import { AccumulateStream } from 'accumulate-stream';

(async (): void => {
  // file.txt: (2kb)
  // streams are awesome.
  // streams are awesome.
  // ... ...
  const readable = createReadStream('file.txt');
  const accumulator = new AccumulateStream({ size: '1kb', phrase: 'awesome' });
  readable.pipe(accumulateStream);

  // will be emitted every 1kb and 2 writes
  accumulator.on('chunk', ({ buffer }) => console.log(`emitted every chunk write - ${buffer.toString()}`));
  accumulator.on('size', ({ buffer }) => console.log(`emitted every 1kb of chunks - ${buffer.toString()}`));
  accumulator.on('phrase', ({ buffer }) =>
    console.log(`emitted whenever "stream" phrase is detected in chunk - ${buffer.toString()}`),
  );
  accumulator.on('data', ({ buffer }) => console.log(`emitted whenever one of the conditions is met - ${buffer.toString()}`));

  await once(accumulator, 'data');
  console.log(accumulator.getBuffer().toString()); // streams are awesome.
})();
```

## API

// [TBD]

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