# stream-util2

> Stream Utilities

Latest version **1.3.1** (published 2022-08-20) · ISC license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.1 |
| Published | 2022-08-20 |
| First published | 2015-12-04 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | monai |
| Maintainers | monai |
| Keywords | stream |

## Links

- npm: https://www.npmjs.com/package/stream-util2
- Repository: https://github.com/monai/node-stream-util2
- Homepage: https://github.com/monai/node-stream-util2#readme
- Issues: https://github.com/monai/node-stream-util2/issues
- npm.io page: https://npm.io/package/stream-util2

## 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.3.1 (latest) — 2022-08-20
- 1.3.0 — 2022-08-20
- 1.2.0 — 2020-10-06
- 1.1.0 — 2020-10-05
- 1.0.0 — 2018-01-25
- 0.0.3 — 2016-02-27
- 0.0.2 — 2015-12-04
- 0.0.1 — 2015-12-04

## README

# stream-util2

[![npm version](http://img.shields.io/npm/v/stream-util2.svg)](https://www.npmjs.org/package/stream-util2)

Various stream utilities.

## Installation

`npm install stream-util2`

## API

### transform(transform, [flush])

Returns a transform stream in object mode.

- `transform` implements [`_transform`](https://nodejs.org/api/stream.html#stream_transform_transform_chunk_encoding_callback). Arguments: `chunk`, `callback`.
- `flush` implements [`_flush`](https://nodejs.org/api/stream.html#stream_transform_flush_callback).

### readable(read)

Returns a readable stream in object mode.

- `read` implements [`_read`](https://nodejs.org/api/stream.html#stream_readable_read_size_1).

### writable(write)

Returns a writable stream in object mode.

- `write` implements [`_write`](https://nodejs.org/api/stream.html#stream_writable_write_chunk_encoding_callback_1). Arguments: `chunk`, `callback`.

### buffer()

Returns a transform stream that buffers chunks of `<Buffer>` type and emits concatenated buffer down the stream.

### toString()

Returns a transform stream that calls `chunk.toString()` for each chunk.

### consoleLog()

Returns a transform stream that calls `console.log(chunk)` for each chunk.

### readArray(array)

Returns a readable stream that reads the array and emits each item down the stream.

### pushArray(array)

Returns a transform stream that pushes each chunk to `array`.

### bufferArray()

Returns a transform stream that buffers chunks to an array and emits it down the stream.

### writeVoid()

Returns a writable stream that does nothing.

### readFunction(options, fn)

Returns a readable stream that generates data from periodic function `fn`.

Options:

- `T` - function period in milliseconds. Default is `1000`.

`fn` arguments:

- `dt` - delta time since beginning of current period.
- `T` - period.

### writePromise([options])

Returns instance of `PromiseWriteStream`, a writable stream that conforms to `Promise`. It buffers data and resolves the promise right before emitting the `finish` event.

Options:

- [`highWaterMark`](https://nodejs.org/api/stream.html#stream_implementing_a_writable_stream).
- [`defaultEncoding`](https://nodejs.org/api/stream.html#stream_implementing_a_writable_stream).

#### PromiseWriteStream

`PromiseWriteStream` is a writable stream that conforms to `Promise`. Internal buffer and promise can be retrieved using `writablePromise.buffer` and `writablePromise.promise`, respectively.

## License

ISC

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