This package provides utilities to convert Node.js `Readable` and `Writable` streams into Web `ReadableStream` and `WritableStream` objects, and vice-versa. It aims to bridge the gap between Node.js's native stream API and the WHATWG Web Streams API, offering stable conversion functions. This is particularly useful because Node.js's own `Readable.toWeb`, `Writable.toWeb`, `Readable.fromWeb`, and `Writable.fromWeb` methods are marked as experimental as of Node.js version 22. The package is currently at version 0.2.1, indicating an early development stage, though it addresses a stable need. It is likely maintained as needed to keep pace with Node.js and Web Streams API evolutions. Key differentiators include providing a non-experimental, stable API surface for stream conversion.
npm install node-web-stream-adaptersVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to convert a Node.js Buffer into a Web ReadableStream using `createReadableStreamFromBuffer` and then consume it.
Always use `import { ... } from 'node-web-stream-adapters'` in your code if you installed the `node-web-stream-adapters` package. Verify the exact package name on npm if unsure, as the README might be outdated or refer to a different package/alias.Monitor Node.js release notes for updates on the Web Streams API and its native integration. For now, using this library provides a robust solution, but be prepared for potential future migration paths if Node.js stabilizes its own converters.
Pin exact versions (e.g., `"node-web-stream-adapters": "0.2.1"`) or use caret ranges (`"^0.2.1"`) with caution, thoroughly reviewing changelogs for any updates. Regular testing is recommended when upgrading minor or patch versions.
Change your import statements to `import { ... } from 'node-web-stream-adapters';`.Ensure you are using ES module `import` syntax: `import { toReadableStream } from 'node-web-stream-adapters';` and check that `type: "module"` is set in your `package.json` if running in Node.js, or use a bundler that handles ESM correctly.No dependency data recorded yet.