Socket
Socket
Sign inDemoInstall

web-streams-polyfill

Package Overview
Dependencies
Maintainers
3
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web-streams-polyfill - npm Package Compare versions

Comparing version 3.1.1 to 4.0.0-beta.1

dist/polyfill.es5.js

19

CHANGELOG.md

@@ -12,2 +12,21 @@ # Changelog

## v4.0.0-beta.1 (2021-09-06)
* 💥 Rework the list of variants to have more modern defaults.
The table below shows how to upgrade your v3 import to their equivalent v4 import.
See the [migration guide](https://github.com/MattiasBuelens/web-streams-polyfill/v4.0.0-beta.1/next/MIGRATING.md) for more information.
([#82](https://github.com/MattiasBuelens/web-streams-polyfill/issues/82), [#83](https://github.com/MattiasBuelens/web-streams-polyfill/pull/83))
* 💥 Remove the ES2018 variant, in favor of the ES2015 variant.
* 🚀 Support [importing as ESM in Node](https://nodejs.org/api/esm.html).
* 💅 Minify all code in the published package, to reduce the download size.
| v3 import | v4 import | description |
| --- | --- | --- |
| `web-streams-polyfill` | `web-streams-polyfill/polyfill/es5` | ES5+ polyfill |
| `web-streams-polyfill/es6` | `web-streams-polyfill/polyfill` | ES2015+ polyfill |
| `web-streams-polyfill/es2018` | `web-streams-polyfill/polyfill` | ES2015+ polyfill |
| `web-streams-polyfill/ponyfill` | `web-streams-polyfill/es5` | ES5+ ponyfill |
| `web-streams-polyfill/ponyfill/es6` | `web-streams-polyfill` | ES2015+ ponyfill |
| `web-streams-polyfill/ponyfill/es2018` | `web-streams-polyfill` | ES2015+ ponyfill |
## v3.1.1 (2021-09-06)

@@ -14,0 +33,0 @@

80

package.json
{
"name": "web-streams-polyfill",
"version": "3.1.1",
"version": "4.0.0-beta.1",
"description": "Web Streams, based on the WHATWG spec reference implementation",
"main": "dist/polyfill",
"browser": "dist/polyfill.min.js",
"module": "dist/polyfill.mjs",
"types": "dist/types/polyfill.d.ts",
"main": "dist/ponyfill.js",
"module": "dist/ponyfill.mjs",
"exports": {
".": {
"import": "./dist/ponyfill.mjs",
"require": "./dist/ponyfill.js"
},
"./es5": {
"import": "./dist/ponyfill.es5.mjs",
"require": "./dist/ponyfill.es5.js"
},
"./polyfill": "./dist/polyfill.js",
"./polyfill/es5": "./dist/polyfill.es5.js",
"./dist/*": "./dist/*",
"./types/*": "./types/*",
"./package": "./package.json",
"./package.json": "./package.json"
},
"types": "types/ponyfill.d.ts",
"typesVersions": {
">=3.6": {
"dist/types/*": [
"dist/types/ts3.6/*"
".": [
"./types/ponyfill.d.ts"
],
"./es5": [
"./types/ponyfill.d.ts"
],
"./polyfill": [
"./types/polyfill.d.ts"
],
"./polyfill/es5": [
"./types/polyfill.d.ts"
]

@@ -17,4 +41,7 @@ }

"scripts": {
"test": "npm run test:types && npm run test:unit && npm run test:wpt",
"test": "npm run test:types && npm run test:unit && npm run test:wpt && npm run test:bundlers",
"test:wpt": "node --expose_gc ./test/run-web-platform-tests.js",
"test:bundlers": "npm run test:rollup && npm run test:webpack",
"test:rollup": "cd test/rollup && npm ci && npm test",
"test:webpack": "cd test/webpack && npm ci && npm test",
"pretest:wpt": "git submodule update --init --recursive",

@@ -26,4 +53,4 @@ "test:types": "tsc -p ./test/types/tsconfig.json",

"build:bundle": "rollup -c",
"build:types": "tsc --project . --emitDeclarationOnly --declarationDir ./lib && api-extractor run && node ./build/downlevel-dts.js",
"accept:types": "tsc --project . --emitDeclarationOnly --declarationDir ./lib && api-extractor run --local && node ./build/downlevel-dts.js",
"build:types": "tsc --project . --emitDeclarationOnly --declarationDir ./lib && api-extractor run",
"accept:types": "tsc --project . --emitDeclarationOnly --declarationDir ./lib && api-extractor run --local",
"prepare": "npm run build"

@@ -33,8 +60,6 @@ },

"dist",
"es6",
"es2018",
"ponyfill"
"types"
],
"engines": {
"node": ">= 8"
"node": ">= 12"
},

@@ -60,21 +85,20 @@ "repository": {

"devDependencies": {
"@microsoft/api-extractor": "^7.13.4",
"@microsoft/api-extractor": "^7.18.7",
"@rollup/plugin-inject": "^4.0.2",
"@rollup/plugin-replace": "^2.4.2",
"@rollup/plugin-strip": "^2.0.0",
"@rollup/plugin-typescript": "^8.2.1",
"@types/node": "^14.14.37",
"@typescript-eslint/eslint-plugin": "^4.21.0",
"@typescript-eslint/parser": "^4.21.0",
"@rollup/plugin-replace": "^3.0.0",
"@rollup/plugin-strip": "^2.1.0",
"@rollup/plugin-typescript": "^8.2.5",
"@types/node": "^14.17.12",
"@typescript-eslint/eslint-plugin": "^4.29.3",
"@typescript-eslint/parser": "^4.29.3",
"@ungap/promise-all-settled": "^1.1.2",
"eslint": "^7.23.0",
"jasmine": "^3.7.0",
"micromatch": "^4.0.2",
"rollup": "^2.44.0",
"eslint": "^7.32.0",
"jasmine": "^3.9.0",
"micromatch": "^4.0.4",
"rollup": "^2.56.3",
"rollup-plugin-terser": "^7.0.2",
"ts-morph": "^10.0.2",
"tslib": "^2.2.0",
"typescript": "^4.2.4",
"tslib": "^2.3.0",
"typescript": "~4.3.5",
"wpt-runner": "^3.2.1"
}
}

@@ -18,23 +18,28 @@ # web-streams-polyfill

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.
* `web-streams-polyfill`: a [ponyfill] that provides the stream implementations
without replacing any globals, targeting ES2015+ environments.
* ✅ Node 6+ through `import` or `require()`
* ✅ Modern web browsers through `import`/`export` or `<script type="module">`
* ✅ Web apps for modern browsers using a bundler (like webpack or Rollup)
* `web-streams-polyfill/es5`: a ponyfill targeting ES5+ environments.
* ✅ Legacy Node through `require()`
* ✅ Legacy web browsers through [AMD][amd]
* ✅ Web apps for legacy browsers using a bundler (like webpack or Rollup)
* `web-streams-polyfill/polyfill`: a polyfill that replaces the native stream implementations,
targeting ES2015+ environments.
* ✅ Modern web browsers through regular `<script>`
* `web-streams-polyfill/polyfill/es5`: a polyfill targeting ES5+ environments.
* ✅ Legacy web browsers through regular `<script>`
Each variant also includes TypeScript type definitions, compatible with the DOM type definitions for streams included in TypeScript.
In version 4, the list of variants was reworked to have more modern defaults and to reduce the download size of the package.
See the [migration guide][migrating] for more information.
Usage as a polyfill:
```html
<!-- option 1: hosted by unpkg CDN -->
<script src="https://unpkg.com/web-streams-polyfill/dist/polyfill.min.js"></script>
<script src="https://unpkg.com/web-streams-polyfill/dist/polyfill.js"></script>
<!-- option 2: self hosted -->
<script src="/path/to/web-streams-polyfill/dist/polyfill.min.js"></script>
<script src="/path/to/web-streams-polyfill/dist/polyfill.js"></script>
<script>

@@ -46,14 +51,21 @@ var readable = new ReadableStream();

```js
var streams = require("web-streams-polyfill/ponyfill");
var streams = require("web-streams-polyfill");
var readable = new streams.ReadableStream();
```
Usage as a ES2015 module:
Usage as a ponyfill from within a ES2015 module:
```js
import { ReadableStream } from "web-streams-polyfill/ponyfill";
import { ReadableStream } from "web-streams-polyfill";
const readable = new ReadableStream();
```
Usage as a polyfill from within an ES2015 module:
```js
import "web-streams-polyfill/polyfill";
const readable = new ReadableStream();
```
### Compatibility
## Compatibility
The `polyfill` and `ponyfill` variants work in any ES5-compatible environment that has a global `Promise`.
The default and `polyfill` variants work in any ES2015-compatible environment.
The `es5` and `polyfill/es5` 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

@@ -63,6 +75,2 @@ (check the [support table][promise-support]), you must first include a `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`][rs-asynciterator] is available in all variants, but requires an ES2018-compatible environment or a polyfill for `Symbol.asyncIterator`.

@@ -72,3 +80,3 @@

### Compliance
## Compliance

@@ -78,10 +86,11 @@ The polyfill implements [version `cada812` (8 Jul 2021)][spec-snapshot] of the streams specification.

The polyfill is tested against the same [web platform tests][wpt] 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][wpt-bad-buffers].
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][proposal-arraybuffer-transfer] to make it possible).
The reference implementation "cheats" on these tests [by making a copy instead][ref-impl-transferarraybuffer], but that is unacceptable for the polyfill's performance ([#3][issue-3]).
* The `es6` variant passes the same tests as the `es2018` variant, except for the [test for the prototype of `ReadableStream`'s async iterator][wpt-async-iterator-prototype].
Retrieving the correct `%AsyncIteratorPrototype%` requires using an async generator (`async function* () {}`), which is invalid syntax before ES2018.
Instead, the polyfill [creates its own version][stub-async-iterator-prototype] 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.
It aims to pass all tests, although it allows some exceptions for practical reasons:
* The default (ES2015) variant passes all of the tests, except for:
* The ["bad buffers and views" tests for readable byte streams][wpt-bad-buffers].
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][proposal-arraybuffer-transfer] to make it possible).
The reference implementation "cheats" on these tests [by making a copy instead][ref-impl-transferarraybuffer], but that is unacceptable for the polyfill's performance ([#3][issue-3]).
* The [test for the prototype of `ReadableStream`'s async iterator][wpt-async-iterator-prototype].
Retrieving the correct `%AsyncIteratorPrototype%` requires using an async generator (`async function* () {}`), which is invalid syntax before ES2018.
Instead, the polyfill [creates its own version][stub-async-iterator-prototype] which is functionally equivalent to the real prototype.
* The ES5 variant passes the same tests as the ES2015 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.

@@ -94,5 +103,5 @@ For example:

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

@@ -107,2 +116,4 @@ Thanks to these people for their work on [the original polyfill][creatorrr-polyfill]:

[ponyfill]: https://github.com/sindresorhus/ponyfill
[amd]: https://requirejs.org/docs/whyamd.html
[migrating]: https://github.com/MattiasBuelens/web-streams-polyfill/v4.0.0-beta.1/next/MIGRATING.md
[promise-support]: https://kangax.github.io/compat-table/es6/#test-Promise

@@ -120,3 +131,3 @@ [promise-polyfill]: https://www.npmjs.com/package/promise-polyfill

[wpt-async-iterator-prototype]: https://github.com/web-platform-tests/wpt/blob/87a4c80598aee5178c385628174f1832f5a28ad6/streams/readable-streams/async-iterator.any.js#L24
[stub-async-iterator-prototype]: https://github.com/MattiasBuelens/web-streams-polyfill/blob/v2.0.0/src/target/es5/stub/async-iterator-prototype.ts
[stub-async-iterator-prototype]: https://github.com/MattiasBuelens/web-streams-polyfill/v4.0.0-beta.1/next/src/lib/readable-stream/async-iterator.ts#L153-L161
[creatorrr-polyfill]: https://github.com/creatorrr/web-streams-polyfill

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc