Sign In

stream-to-value

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-to-value

Consume a Web ReadableStream into a string, Uint8Array, JSON object, or array of chunks

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

stream-to-value

Consume a Web ReadableStream into a string, Uint8Array, JSON object, or array of chunks

Install

npm install stream-to-value

Usage

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);

API

streamToString(readableStream)

Consume a ReadableStream into a string. Handles both string and Uint8Array chunks.

Returns a Promise<string>.

readableStream

Type: ReadableStream

The stream to consume.

streamToUint8Array(readableStream)

Consume a ReadableStream into a single Uint8Array.

Returns a Promise<Uint8Array>.

readableStream

Type: ReadableStream

The stream to consume.

streamToJson(readableStream)

Consume a ReadableStream and parse the content as JSON.

Returns a Promise<unknown>.

readableStream

Type: ReadableStream

The stream to consume.

streamToArray(readableStream)

Consume a ReadableStream into an array of chunks.

Returns a Promise<unknown[]>.

readableStream

Type: ReadableStream

The stream to consume.

  • web-streams-polyfill - Web Streams API polyfill

License

MIT

Keywords

stream

FAQs

Package last updated on 16 Feb 2026

Did you know?

Socket

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.

Install

Related posts