All Projects → MattiasBuelens → web-streams-polyfill

MattiasBuelens / web-streams-polyfill

Licence: MIT License
Web Streams, based on the WHATWG spec reference implementation

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to web-streams-polyfill

Css Vars Ponyfill
Client-side support for CSS custom properties (aka "CSS variables") in legacy and modern browsers
Stars: ✭ 1,166 (+488.89%)
Mutual labels:  polyfill, ponyfill
fromentries
Object.fromEntries() ponyfill (in 6 lines)
Stars: ✭ 62 (-68.69%)
Mutual labels:  polyfill, ponyfill
Resize Observer Polyfill
A polyfill for the Resize Observer API
Stars: ✭ 1,530 (+672.73%)
Mutual labels:  polyfill, ponyfill
Clipboard Polyfill
📋 Simple copying on the web, with maximum browser compatibility.
Stars: ✭ 748 (+277.78%)
Mutual labels:  polyfill, ponyfill
godsend
A simple and eloquent workflow for streaming messages to micro-services.
Stars: ✭ 15 (-92.42%)
Mutual labels:  stream, streams
Scroll Into View If Needed
Element.scrollIntoView ponyfills for things like "if-needed" and "smooth"
Stars: ✭ 811 (+309.6%)
Mutual labels:  polyfill, ponyfill
Core Js
Standard Library
Stars: ✭ 15,854 (+7907.07%)
Mutual labels:  polyfill, ponyfill
Promise Fun
Promise packages, patterns, chat, and tutorials
Stars: ✭ 3,779 (+1808.59%)
Mutual labels:  polyfill, ponyfill
go-streams
Stream Collections for Go. Inspired in Java 8 Streams and .NET Linq
Stars: ✭ 127 (-35.86%)
Mutual labels:  stream, streams
fetch
A fetch API polyfill for React Native with text streaming support.
Stars: ✭ 27 (-86.36%)
Mutual labels:  polyfill, streams
Unfetch
🐕 Bare minimum 500b fetch polyfill.
Stars: ✭ 5,239 (+2545.96%)
Mutual labels:  polyfill, ponyfill
o9n
🖥 A screen.orientation ponyfill
Stars: ✭ 55 (-72.22%)
Mutual labels:  polyfill, ponyfill
Resize Observer
Polyfills the ResizeObserver API.
Stars: ✭ 540 (+172.73%)
Mutual labels:  polyfill, ponyfill
Ponyfill
🦄 Like polyfill but with pony pureness
Stars: ✭ 945 (+377.27%)
Mutual labels:  polyfill, ponyfill
Fakeindexeddb
A pure JS in-memory implementation of the IndexedDB API
Stars: ✭ 373 (+88.38%)
Mutual labels:  polyfill, ponyfill
Tickedoff
Tiny library (<200B gzip) for deferring something by a "tick"
Stars: ✭ 213 (+7.58%)
Mutual labels:  polyfill, ponyfill
Multistream
A stream that emits multiple other streams one after another (streams3)
Stars: ✭ 237 (+19.7%)
Mutual labels:  stream, streams
Abortcontroller Polyfill
Polyfill for the AbortController DOM API and abortable fetch (stub that calls catch, doesn't actually abort request).
Stars: ✭ 273 (+37.88%)
Mutual labels:  polyfill, ponyfill
streamplify
Java 8 combinatorics-related streams and other utilities
Stars: ✭ 40 (-79.8%)
Mutual labels:  stream, streams
wasm-streams
Bridging between web streams and Rust streams using WebAssembly
Stars: ✭ 61 (-69.19%)
Mutual labels:  stream, streams

web-streams-polyfill

Web Streams, based on the WHATWG spec reference implementation.

build status npm version license Join the chat at https://gitter.im/web-streams-polyfill/Lobby

Links

Usage

This library comes in multiple variants:

  • web-streams-polyfill: a polyfill that replaces the native stream implementations. Recommended for use in web apps supporting older browsers through a <script> tag.
  • web-streams-polyfill/es6: a polyfill targeting ES2015+ environments. Recommended for use in web apps supporting modern browsers through a <script> tag.
  • web-streams-polyfill/es2018: a polyfill targeting ES2018+ environments.
  • web-streams-polyfill/ponyfill: a ponyfill that provides the stream implementations without replacing any globals. Recommended for use in legacy Node applications, or in web libraries supporting older browsers.
  • web-streams-polyfill/ponyfill/es6: a ponyfill targeting ES2015+ environments. Recommended for use in Node 6+ applications, or in web libraries supporting modern browsers.
  • web-streams-polyfill/ponyfill/es2018: a ponyfill targeting ES2018+ environments. Recommended for use in Node 10+ applications.

Each variant also includes TypeScript type definitions, compatible with the DOM type definitions for streams included in TypeScript.

Usage as a polyfill:

<!-- option 1: hosted by unpkg CDN -->
<script src="https://unpkg.com/web-streams-polyfill/dist/polyfill.min.js"></script>
<!-- option 2: self hosted -->
<script src="/path/to/web-streams-polyfill/dist/polyfill.min.js"></script>
<script>
var readable = new ReadableStream();
</script>

Usage as a Node module:

var streams = require("web-streams-polyfill/ponyfill");
var readable = new streams.ReadableStream();

Usage as a ES2015 module:

import { ReadableStream } from "web-streams-polyfill/ponyfill";
const readable = new ReadableStream();

Compatibility

The polyfill and ponyfill variants work in any ES5-compatible environment that has a global Promise. If you need to support older browsers or Node versions that do not have a native Promise implementation (check the support table), you must first include a Promise polyfill (e.g. promise-polyfill).

The polyfill/es6 and ponyfill/es6 variants work in any ES2015-compatible environment.

The polyfill/es2018 and ponyfill/es2018 variants work in any ES2018-compatible environment.

Async iterable support for ReadableStream is available in all variants, but requires an ES2018-compatible environment or a polyfill for Symbol.asyncIterator.

WritableStreamDefaultController.signal is available in all variants, but requires a global AbortController constructor. If necessary, consider using a polyfill such as abortcontroller-polyfill.

Compliance

The polyfill implements version 4b6b93c (25 Oct 2021) of the streams specification.

The polyfill is tested against the same web platform tests that are used by browsers to test their native implementations. The polyfill aims to pass all tests, although it allows some exceptions for practical reasons:

  • The es2018 variant passes all of the tests, except for the "bad buffers and views" tests for readable byte streams. These tests require the implementation to synchronously transfer the contents of an ArrayBuffer, which is not yet possible from JavaScript (although there is a proposal to make it possible). The reference implementation "cheats" on these tests by making a copy instead, but that is unacceptable for the polyfill's performance (#3).
  • The es6 variant passes the same tests as the es2018 variant, except for the test for the prototype of ReadableStream's async iterator. Retrieving the correct %AsyncIteratorPrototype% requires using an async generator (async function* () {}), which is invalid syntax before ES2018. Instead, the polyfill creates its own version which is functionally equivalent to the real prototype.
  • The es5 variant passes the same tests as the es6 variant, except for various tests about specific characteristics of the constructors, properties and methods. These test failures do not affect the run-time behavior of the polyfill. For example:
    • The name property of down-leveled constructors is incorrect.
    • The length property of down-leveled constructors and methods with optional arguments is incorrect.
    • Not all properties and methods are correctly marked as non-enumerable.
    • Down-leveled class methods are not correctly marked as non-constructable.

The type definitions are compatible with the built-in stream types of TypeScript 3.3.

Contributors

Thanks to these people for their work on the original polyfill:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].