forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstreams.ts
More file actions
27 lines (24 loc) · 666 Bytes
/
Copy pathstreams.ts
File metadata and controls
27 lines (24 loc) · 666 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**
* Polyfill: ReadableStream, WritableStream, TransformStream
*
* Required for SSE streaming in CopilotKit.
* Skipped individually if the global already has each class defined.
*
* Usage:
* import "@copilotkit/react-native/polyfills/streams";
*/
import {
ReadableStream,
WritableStream,
TransformStream,
} from "web-streams-polyfill";
const g = globalThis as Record<string, unknown>;
if (typeof g.ReadableStream === "undefined") {
g.ReadableStream = ReadableStream;
}
if (typeof g.WritableStream === "undefined") {
g.WritableStream = WritableStream;
}
if (typeof g.TransformStream === "undefined") {
g.TransformStream = TransformStream;
}