npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

web-streams-shim

v1.0.8

Published

🛶 Web Streams Shim is designed to create parity between the streaming interfaces within modern runtimes. This does not polyfill the interfaces if they are missing entirely. For that you will want [web-streams-polyfill](https://www.npmjs.com/package/web-s

Readme

Web Streams Shim

🛶 Web Streams Shim is designed to create parity between the streaming interfaces within modern runtimes. This does not polyfill the interfaces if they are missing entirely. For that you will want web-streams-polyfill which is not affiliated with the project.

This library provides essential polyfills and shims to ensure modern Web Streams functionality is available and compliant across environments where native support is missing or incomplete, particularly focusing on ReadableStream, Request, Response, and Blob objects.

Install

At the top of your web page put

<script src="https://cdn.jsdelivr.net/npm/web-streams-shim/web-streams-core.js"></script>

Dynamic import

await import('https://cdn.jsdelivr.net/npm/web-streams-shim/web-streams-core.js');


Key Features and Polyfills

The library focuses on extending core browser APIs to meet the latest Web Stream and Fetch specifications. Compatibility tables are generated dynamically from mdn's caniuse api.

Conditional Filling

Each polyfill performs feature detection before initializing. If a feature is detected as already present then it is skipped so as not to overwrite native behavior where possible.

ReadableStream Async Iteration

The library adds comprehensive support for modern JavaScript iteration patterns to ReadableStream and its readers.

ReadableStream.asyncIterator | | | | | :--- | :--- | :--- | | ReadableStream | [Symbol.asyncIterator] | Allows the stream to be directly iterable in for-await-of loops. |

ReadableStream.values | | | | | :--- | :--- | :--- | | ReadableStream | values() | An alias for [Symbol.asyncIterator] for explicit iteration. |

Stream Construction Utility

The library adds the static method for creating streams from existing data sources.

ReadableStream.from | | | | | :--- | :--- | :--- | | ReadableStream | from(obj) | Creates a new ReadableStream from any iterable or async iterable object. It handles both synchronous and asynchronous iterators, including objects that yield Promise-like values. |

Body Shim

This shim ensures Request and Response objects consistently expose their body as a stream.

Request.body | | | | | :--- | :--- | :--- | | Request | body | Polyfills the body property to return a ReadableStream representation of the body content. This is crucial for environments where fetch exists but streaming is absent. |

Response.body | | | | | :--- | :--- | :--- | | Response | body | Provides the body content as a ReadableStream. |

Bytes Shim

This shim ensures Request and Response, and Blob objects consistently provide the bytes() utility.

Request.bytes | | | | | :--- | :--- | :--- | | Request | bytes() | Adds the bytes() method, which asynchronously returns the object's body/content as a Uint8Array. |

Response.bytes | | | | | :--- | :--- | :--- | | Response | bytes() | Adds the bytes() method, which asynchronously returns the object's body/content as a Uint8Array. |

Blob.bytes | | | | | :--- | :--- | :--- | | Blob | bytes() | Adds the bytes() method, which asynchronously returns the object's body/content as a Uint8Array. |

Duplex Compliance Shim

To satisfy modern fetch specifications when streaming request bodies, the library ensures compliance for half-duplex operations. This is in many ways a reverse shim as it allows legacy code to continue to work in the absence of a duplex parameter that did not exist when the code was implemented.

  • Property Injection: The duplex: 'half' property is added to the prototypes of Request, Response, ReadableStream, and Blob.
  • Constructor Wrapping: The global Request and Response constructors are subclassed and wrapped to automatically apply duplex: 'half' utility function to all arguments passed during instantiation.
  • Fetch Wrapping: The global fetch function is wrapped to automatically apply duplex: 'half' to its arguments before execution, guaranteeing compliance when streams are used in options.

Request.duplex

ReadableStreamDefaultReader Constructor Support

The library adds support for the ReadableStreamDefaultReader constructor.

ReadableStreamDefaultReader.constructor | | | | | :--- | :--- | :--- | | ReadableStreamDefaultReader | constructor(stream) | Polyfills the ReadableStreamDefaultReader constructor to accept a stream directly. In environments where the native constructor doesn't support this (like Bun), it delegates to stream.getReader() and properly sets up the prototype chain. This allows new ReadableStreamDefaultReader(stream) to work consistently across all runtimes. |

Additional Shims

ReadableStreamBYOBReader

ReadableStreamBYOBReader.constructor

ReadableStreamBYOBRequest

ReadableByteStreamContoller

ReadableByteStreamContoller.byobRequest