# @zenfs/streams

> A modern node:stream polyfill

Latest version **1.0.2** (published 2026-10-28) · LGPL-3.0-or-later license · 0 weekly downloads

## Install

```sh
npm install @zenfs/streams
pnpm add @zenfs/streams
yarn add @zenfs/streams
bun add @zenfs/streams
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2026-10-28 |
| First published | 2026-09-07 |
| Weekly downloads | 0 |
| License | LGPL-3.0-or-later |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 22 |
| Dependencies | 2 |
| Unpacked size | 260.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 0 |
| Author | James Prevett |
| Maintainers | james-pre |
| Keywords | stream, streams, node, polyfill, browser |

## Links

- npm: https://www.npmjs.com/package/@zenfs/streams
- Repository: https://github.com/zen-fs/streams
- Issues: https://github.com/zen-fs/streams/issues
- Funding: https://github.com/sponsors/james-pre
- npm.io page: https://npm.io/package/@zenfs/streams

## Dependencies (2)

- [buffer](https://npm.io/package/buffer.md) ^6.0.3
- [@types/node](https://npm.io/package/@types/node.md) ^26.0.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2026-10-28
- 1.0.1 — 2026-09-11
- 1.0.0 — 2026-09-08
- 0.0.1 — 2026-09-07

## README

# ZenFS Streams

A modern polyfill for [`node:stream`](https://nodejs.org/api/stream.html).

This package replaces [`readable-stream`](https://github.com/nodejs/readable-stream) in [ZenFS](https://github.com/zen-fs/core). `readable-stream` made up 10 of the 17 dependencies in the `@zenfs/core` tree and totaled 703 KB unpacked, and it has a number of unresolved problems with its types and legacy code.

It is written in TypeScript against Node's current implementation, and every exported class is declared `implements` its `node:stream` counterpart.

## Usage

```js
import { Readable, Writable, pipeline } from '@zenfs/streams';

await pipeline(
	Readable.from(['hello', ' ', 'world']),
	new Writable({
		write(chunk, encoding, callback) {
			console.log(chunk.toString());
			callback();
		},
	})
);
```

## Notes

- The only runtime dependency is [`buffer`](https://github.com/feross/buffer), which resolves to the built-in module on Node. `events`, `process`, `abort-controller` and `string_decoder` are not needed: `EventEmitter` and `StringDecoder` are implemented here, and `AbortController` and `queueMicrotask` are used directly.
- `StringDecoder` decodes UTF-8 with a streaming `TextDecoder`. UTF-16LE is handled separately, since Node drops a trailing odd byte and preserves lone surrogates where the WHATWG decoder replaces both with U+FFFD.
- Outside Node there is no `process.nextTick`, so callbacks fall back to `queueMicrotask`. Node drains its next-tick queue ahead of the microtask queue; the fallback has no equivalent, so those callbacks interleave with promise continuations rather than preceding them.
- `finished()` on a WHATWG stream needs the closed-promise symbol that `node:stream` (and this package's `toWeb()`) attaches. A plain `ReadableStream` cannot be observed without consuming it, so it is rejected.
- `setMaxListeners` is honored as state but never produces Node's `MaxListenersExceededWarning`.

## License

[@zenfs/streams](https://github.com/zen-fs/streams) is licensed under the [LGPL 3.0 or later](https://www.gnu.org/licenses/lgpl-3.0.html) and [COPYING.md](https://github.com/zen-fs/streams/blob/main/COPYING.md).
Copyright © James Prevett and other ZenFS contributors.

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