experimental-fast-webstreams 0.0.1 → 0.0.3
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 +1 -1
- package/package.json +4 -3
- package/src/edge.js +23 -0
- package/types/index.d.ts +6 -0
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ These are drop-in replacements for the global `ReadableStream`, `WritableStream`
|
|
|
43
43
|
To replace the built-in stream constructors globally:
|
|
44
44
|
|
|
45
45
|
```js
|
|
46
|
-
import { patchGlobalWebStreams, unpatchGlobalWebStreams } from 'experimental-fast-webstreams
|
|
46
|
+
import { patchGlobalWebStreams, unpatchGlobalWebStreams } from 'experimental-fast-webstreams';
|
|
47
47
|
|
|
48
48
|
patchGlobalWebStreams();
|
|
49
49
|
// globalThis.ReadableStream is now FastReadableStream
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "experimental-fast-webstreams",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Exploring faster WebStreams for Node.js",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
9
|
"types": "./types/index.d.ts",
|
|
10
|
+
"edge-light": "./src/edge.js",
|
|
11
|
+
"workerd": "./src/edge.js",
|
|
10
12
|
"default": "./src/index.js"
|
|
11
|
-
}
|
|
12
|
-
"./patch": "./src/patch.js"
|
|
13
|
+
}
|
|
13
14
|
},
|
|
14
15
|
"engines": {
|
|
15
16
|
"node": ">=20"
|
package/src/edge.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edge runtime shim: re-exports the native globals as-is.
|
|
3
|
+
*
|
|
4
|
+
* Edge runtimes (Vercel Edge, Cloudflare Workers) already have fast
|
|
5
|
+
* WebStreams implementations and don't support node:stream.
|
|
6
|
+
* This module provides the same API surface so imports resolve
|
|
7
|
+
* without pulling in Node.js-specific modules.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export const FastReadableStream = ReadableStream;
|
|
11
|
+
export const FastWritableStream = WritableStream;
|
|
12
|
+
export const FastTransformStream = TransformStream;
|
|
13
|
+
export const FastReadableStreamDefaultReader = ReadableStreamDefaultReader;
|
|
14
|
+
export const FastWritableStreamDefaultWriter = WritableStreamDefaultWriter;
|
|
15
|
+
|
|
16
|
+
// No BYOB reader export — edge runtimes support it natively via getReader({ mode: 'byob' })
|
|
17
|
+
export const FastReadableStreamBYOBReader = ReadableStreamBYOBReader;
|
|
18
|
+
|
|
19
|
+
/** No-op on edge — streams are already fast. */
|
|
20
|
+
export function patchGlobalWebStreams() {}
|
|
21
|
+
|
|
22
|
+
/** No-op on edge. */
|
|
23
|
+
export function unpatchGlobalWebStreams() {}
|
package/types/index.d.ts
CHANGED
|
@@ -49,3 +49,9 @@ export declare const FastWritableStreamDefaultWriter: {
|
|
|
49
49
|
new <W = any>(stream: WritableStream<W>): WritableStreamDefaultWriter<W>;
|
|
50
50
|
prototype: WritableStreamDefaultWriter;
|
|
51
51
|
};
|
|
52
|
+
|
|
53
|
+
/** Replace global ReadableStream, WritableStream, TransformStream with fast alternatives. */
|
|
54
|
+
export declare function patchGlobalWebStreams(): void;
|
|
55
|
+
|
|
56
|
+
/** Restore the original native stream constructors. */
|
|
57
|
+
export declare function unpatchGlobalWebStreams(): void;
|