web-streams-shim 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,13 +31,13 @@ Each polyfill performs feature detection before initializing. If a feature is de
|
|
|
31
31
|
The library adds **comprehensive support for modern JavaScript iteration patterns** to `ReadableStream` and its readers.
|
|
32
32
|
|
|
33
33
|

|
|
34
|
-
|
|
35
34
|
| | | |
|
|
36
35
|
| :--- | :--- | :--- |
|
|
37
36
|
| [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) | [`[Symbol.asyncIterator]`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncIterator) | Allows the stream to be directly iterable in `for-await-of` loops. |
|
|
38
37
|
|
|
39
|
-
|
|
38
|
+
⠀
|
|
40
39
|
|
|
40
|
+

|
|
41
41
|
| | | |
|
|
42
42
|
| :--- | :--- | :--- |
|
|
43
43
|
| [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) | `values()` | An alias for `[Symbol.asyncIterator]` for explicit iteration. |
|
|
@@ -47,24 +47,25 @@ The library adds **comprehensive support for modern JavaScript iteration pattern
|
|
|
47
47
|
|
|
48
48
|
The library adds the static method for creating streams from existing data sources.
|
|
49
49
|
|
|
50
|
+

|
|
50
51
|
| | | |
|
|
51
52
|
| :--- | :--- | :--- |
|
|
52
53
|
| [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) | [`from(obj)`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/from_static) | **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. |
|
|
53
54
|
|
|
54
|
-
|
|
55
|
+
|
|
55
56
|
|
|
56
57
|
### Body Shim
|
|
57
58
|
|
|
58
59
|
This shim ensures `Request` and `Response` objects consistently expose their body as a stream.
|
|
59
60
|
|
|
60
61
|

|
|
61
|
-
|
|
62
62
|
| | | |
|
|
63
63
|
| :--- | :--- | :--- |
|
|
64
64
|
| [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request/body) | [`body`](https://developer.mozilla.org/en-US/docs/Web/API/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. |
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
⠀
|
|
67
67
|
|
|
68
|
+

|
|
68
69
|
| | | |
|
|
69
70
|
| :--- | :--- | :--- |
|
|
70
71
|
| [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response/body) | [`body`](https://developer.mozilla.org/en-US/docs/Web/API/Response/body) | Provides the body content as a `ReadableStream`. |
|
|
@@ -75,19 +76,20 @@ This shim ensures `Request` and `Response` objects consistently expose their bod
|
|
|
75
76
|
This shim ensures `Request` and `Response`, and `Blob` objects consistently provide the `bytes()` utility.
|
|
76
77
|
|
|
77
78
|

|
|
78
|
-
|
|
79
79
|
| | | |
|
|
80
80
|
| :--- | :--- | :--- |
|
|
81
81
|
| [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request/bytes) | [`bytes()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) | Adds the `bytes()` method, which **asynchronously returns the object's body/content as a `Uint8Array`**. |
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
⠀
|
|
84
84
|
|
|
85
|
+

|
|
85
86
|
| | | |
|
|
86
87
|
| :--- | :--- | :--- |
|
|
87
88
|
| [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response/bytes) | [`bytes()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) | Adds the `bytes()` method, which **asynchronously returns the object's body/content as a `Uint8Array`**. |
|
|
88
89
|
|
|
89
|
-
|
|
90
|
+
⠀
|
|
90
91
|
|
|
92
|
+

|
|
91
93
|
| | | |
|
|
92
94
|
| :--- | :--- | :--- |
|
|
93
95
|
| [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob/bytes) | [`bytes()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) | Adds the `bytes()` method, which **asynchronously returns the object's body/content as a `Uint8Array`**. |
|
|
@@ -109,7 +111,6 @@ To satisfy modern `fetch` specifications when streaming request bodies, the libr
|
|
|
109
111
|
The library adds support for the `ReadableStreamDefaultReader` constructor.
|
|
110
112
|
|
|
111
113
|

|
|
112
|
-
|
|
113
114
|
| | | |
|
|
114
115
|
| :--- | :--- | :--- |
|
|
115
116
|
| [`ReadableStreamDefaultReader`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultReader) | [`constructor(stream)`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultReader/ReadableStreamDefaultReader) | **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. |
|
|
@@ -123,7 +124,8 @@ The library adds support for the `ReadableStreamDefaultReader` constructor.
|
|
|
123
124
|
|
|
124
125
|

|
|
125
126
|
|
|
126
|
-

|
|
127
128
|
|
|
129
|
+

|
|
128
130
|
|
|
129
131
|

|