Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
readable-web-to-node-stream
Advanced tools
Converts a Web-API readable-stream into a Node 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.
Install via npm:
npm install readable-web-to-node-stream
or or yarn:
yarn add readable-web-to-node-stream
Source is written in TypeScript and compiled to ECMAScript 2017 (ES8).
Unit tests are performed on the following browsers:
Import readable-web-stream-to-node in JavaScript:
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);
}
constructor(stream: ReadableStream): Promise
stream: ReadableStream
: the Web-API readable stream.
close(): Promise Will cancel close the Readable-node stream, and will release Web-API-readable-stream.
waitForReadToComplete(): Promise If there is no unresolved read call to Web-API ReadableStream immediately returns, otherwise it will wait until the read is resolved.
(The MIT License)
Copyright (c) 2019 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 readable-stream.
The npm package readable-web-to-node-stream receives a total of 3,555,023 weekly downloads. As such, readable-web-to-node-stream popularity was classified as popular.
We found that readable-web-to-node-stream demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.