# easy-transform-stream

> Create a transform stream using await instead of callbacks

Latest version **1.0.1** (published 2023-10-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install easy-transform-stream
pnpm add easy-transform-stream
yarn add easy-transform-stream
bun add easy-transform-stream
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2023-10-31 |
| First published | 2022-01-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=14.16 |
| Dependencies | 0 |
| Unpacked size | 5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 69 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | stream, transform, async, function, await, through |

## Links

- npm: https://www.npmjs.com/package/easy-transform-stream
- Repository: https://github.com/sindresorhus/easy-transform-stream
- Homepage: https://github.com/sindresorhus/easy-transform-stream#readme
- Issues: https://github.com/sindresorhus/easy-transform-stream/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/easy-transform-stream

## 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.1 (latest) — 2023-10-31
- 1.0.0 — 2022-06-03
- 0.1.0 — 2022-01-24

## README

# easy-transform-stream

> Create a transform stream using await instead of callbacks

The built-in [`stream.Transform` constructor](https://nodejs.org/api/stream.html#class-streamtransform) forces you to deal with a callback interface. It's much nicer to just be able to await and return a value.

This package can be thought of as a modern version of [`through2`](https://github.com/rvagg/through2).

## Install

```sh
npm install easy-transform-stream
```

## Usage

```js
import transformStream from 'easy-transform-stream';

const stream = transformStream(async chunk => {
	const newChunk = await modifyChunk(chunk);
	return newChunk;
});
```

## API

### easyTransformStream(transformer, flusher?)
### easyTransformStream(options, transformer, flusher?)

#### transformer(chunk, encoding, stream)

Type: Async function

Receives each chunk and is expected to return a transformed chunk.

#### flusher(stream)

Type: Async generator function

Yield additional chunks at the end of the stream.

#### options

Type: `object`

Same as the [options for `stream.Transform`](https://nodejs.org/api/stream.html#new-streamtransformoptions), except for `transform` and `flush`.

## Related

- [get-stream](https://github.com/sindresorhus/get-stream) - Get a stream as a string, buffer, or array

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