
Security News
White House Authorizes Private Companies to Conduct Offensive Cyber Operations
A new federal program will let vetted U.S. cybersecurity firms help investigate and disrupt foreign cybercrime groups under government direction.
stream-to-value
Advanced tools
Consume a Web ReadableStream into a string, Uint8Array, JSON object, or array of chunks
Consume a Web ReadableStream into a string, Uint8Array, JSON object, or array of chunks
npm install stream-to-value
import {streamToString, streamToJson} from 'stream-to-value';
const response = await fetch('https://example.com/api');
const text = await streamToString(response.body);
console.log(text);
const response2 = await fetch('https://example.com/api/data');
const data = await streamToJson(response2.body);
console.log(data);
Consume a ReadableStream into a string. Handles both string and Uint8Array chunks.
Returns a Promise<string>.
Type: ReadableStream
The stream to consume.
Consume a ReadableStream into a single Uint8Array.
Returns a Promise<Uint8Array>.
Type: ReadableStream
The stream to consume.
Consume a ReadableStream and parse the content as JSON.
Returns a Promise<unknown>.
Type: ReadableStream
The stream to consume.
Consume a ReadableStream into an array of chunks.
Returns a Promise<unknown[]>.
Type: ReadableStream
The stream to consume.
MIT
FAQs
Consume a Web ReadableStream into a string, Uint8Array, JSON object, or array of chunks
We found that stream-to-value demonstrated a healthy version release cadence and project activity because the last version was released less than 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.

Security News
A new federal program will let vetted U.S. cybersecurity firms help investigate and disrupt foreign cybercrime groups under government direction.

Research
/Security News
The campaign amassed more than 75,000 installs by targeting Russian-speaking users seeking access to blocked services.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.