
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
readable-web-to-node-stream
Advanced tools
Converts a Web-API readable-stream into a Node.js readable-stream.
The readable-web-to-node-stream package provides a way to convert web streams (ReadableStream) into Node.js streams (Readable). This is particularly useful for working with web APIs in a Node.js environment, allowing seamless integration between web and Node.js stream ecosystems.
Convert Web ReadableStream to Node.js Readable Stream
This feature allows you to convert a web ReadableStream obtained from a fetch request into a Node.js Readable stream. The code sample demonstrates fetching data from a URL and converting the response body into a Node.js stream, which can then be used with Node.js stream APIs.
const { ReadableWebToNodeStream } = require('readable-web-to-node-stream');
async function fetchAndConvert(url) {
const response = await fetch(url);
const webStream = response.body;
const nodeStream = new ReadableWebToNodeStream(webStream);
nodeStream.on('data', chunk => {
console.log('Received chunk:', chunk);
});
}
fetchAndConvert('https://example.com');
The web-streams-polyfill package provides a polyfill for the Web Streams API, making it available in environments where it is not natively supported. Unlike readable-web-to-node-stream, it focuses on providing the Web Streams API itself rather than converting between web and Node.js streams.
The node-fetch package is a lightweight module that brings `window.fetch` to Node.js. While it does not directly convert web streams to Node.js streams, it allows you to use the Fetch API in Node.js, which can be used in conjunction with readable-web-to-node-stream for stream conversion.
The stream-web package provides utilities for working with web streams in Node.js. It includes functions for converting between web streams and Node.js streams, similar to readable-web-to-node-stream, but offers a broader set of utilities for stream manipulation.
Converts a Web-API readable stream into a Node.js readable stream.
To covert the other way around, from Node.js readable stream to Web-API readable stream, you may use node-readable-to-web-readable-stream.
Install via npm:
npm install readable-web-to-node-stream
or yarn:
yarn add readable-web-to-node-stream
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.
Example, import readable-web-stream-to-node in JavaScript:
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:
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.
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.(The MIT License)
Copyright (c) 2025 Borewit
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
Converts a Web-API readable-stream into a Node.js readable-stream.
The npm package readable-web-to-node-stream receives a total of 4,160,964 weekly downloads. As such, readable-web-to-node-stream popularity was classified as popular.
We found that readable-web-to-node-stream demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.