Registry / storage / fetch-readablestream

fetch-readablestream

JSON →
library0.2.0jsnpmunverified

Compatibility layer for efficient streaming of binary data using WHATWG Streams. Current stable version is 0.2.0, with no recent releases or cadence. It provides a consistent cross-browser API to stream HTTP responses as ReadableStream, falling back to XMLHttpRequest with moz-chunked-arraybuffer in Firefox, and TextEncoder in other browsers. Differentiates from native fetch by enabling streaming in older browsers, unlike stream-http which uses callbacks.

npm install fetch-readablestream
INSTALL
IMPORT
SIG · FETCH-READABLESTRE
F
fetch-readablestream
storagejavascriptv0.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

fetchStream
✓ import fetchStream from 'fetch-readablestream'
✗ const fetchStream = require('fetch-readablestream')
Package is ESM-only; CommonJS require will fail.
fetchStream (global)
✓ <!-- script src='fetch-readablestream.js' --> window.fetchStream('...')
Global usage via dist bundle, no import needed.

Demonstrates streaming a response body as text using fetchStream and a ReadableStream reader.

import fetchStream from 'fetch-readablestream'; async function streamResponse(url) { const response = await fetchStream(url); const reader = response.body.getReader(); const decoder = new TextDecoder(); let result = ''; while (true) { const { done, value } = await reader.read(); if (done) break; result += decoder.decode(value, { stream: true }); } decoder.decode(); // flush return result; } streamResponse('https://example.com').then(console.log);
Debug
Known issues
gotchafetchStream only supports GET requests; POST not implemented.
fix
Use native fetch or XMLHttpRequest for POST.
affects: >=0.0.0
deprecatedAbortController support is limited; need polyfill in many environments.
fix
Include abortcontroller-polyfill if targeting older browsers.
affects: >=0.1.0
gotchaResponse.body may be null if not streaming; always check before reading.
fix
Guard with if (response.body) before calling getReader().
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: fetchStream is not a function
CommonJS require used instead of ESM import.
fix
Use import fetchStream from 'fetch-readablestream'
TypeError: Failed to execute 'getReader' on 'ReadableStream': reader is already active.
Multiple concurrent reads on same stream without releasing reader.
fix
Close reader after use with reader.releaseLock() or let stream cancel.
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
16
Resources
fetch-readablestream — npm install fetch-readablestream · libregistry