Converts a Web-API readable-stream into a Node.js readable-stream.
npm install readable-web-to-node-stream





bash
npm install readable-web-to-node-stream
`
or yarn:
`bash
yarn add readable-web-to-node-stream
`
Compatibility
Version 4 migrated from CommonJS (CJS) to a pure ECMAScript module (ESM).
The ESM has a _Node_ and a _default_ entry point.
Source is written in TypeScript and compiled to ECMAScript ES2020 (ES11).
The _Node_ entry requires a Node.js ≥ 18 engine.
Usage
Example, import readable-web-stream-to-node in JavaScript:
`js
import { ReadableWebToNodeStream } from 'readable-web-to-node-stream';
async function download(url) {
const response = await fetch(url);
const readableWebStream = response.body;
const nodeStream = new ReadableWebToNodeStream(readableWebStream);
}
`
For Node.js ≥ 22, should also work in a CommonJS projects:
`js
const {ReadableWebToNodeStream} = require('readable-web-to-node-stream');
async function download(url) {
const response = await fetch(url);
const readableWebStream = response.body;
const nodeStream = new ReadableWebToNodeStream(readableWebStream);
}
`
For TypeScript / CommonJS projects, not using Node.js ≥ 22, check load-esm.
API
constructor(stream: ReadableStream, options): Promise
- stream: ReadableStream: the Web-API readable stream.
- options?: {propagateDestroy: boolean}
- propagateDestroy, default value is false, if set to true`, will also cancel the _stream_ when the Node.js Readable is destroyed.