-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathvitest.polyfills.ts
More file actions
25 lines (23 loc) · 852 Bytes
/
Copy pathvitest.polyfills.ts
File metadata and controls
25 lines (23 loc) · 852 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
import { TextEncoder, TextDecoder } from "util";
import { ReadableStream, TransformStream } from "stream/web";
if (typeof global.TextEncoder === "undefined") {
global.TextEncoder = TextEncoder;
}
if (typeof global.TextDecoder === "undefined") {
global.TextDecoder = TextDecoder as typeof global.TextDecoder;
}
if (typeof global.ReadableStream === "undefined") {
global.ReadableStream = ReadableStream as typeof global.ReadableStream;
}
if (typeof global.TransformStream === "undefined") {
global.TransformStream = TransformStream as typeof global.TransformStream;
}
if (typeof global.Request === "undefined") {
global.Request = class Request {} as any;
}
if (typeof global.Response === "undefined") {
global.Response = class Response {} as any;
}
if (typeof global.Headers === "undefined") {
global.Headers = class Headers {} as any;
}