-
Notifications
You must be signed in to change notification settings - Fork 235
/
node_shims.ts
67 lines (62 loc) · 1.57 KB
/
node_shims.ts
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright 2018-2024 the oak authors. All rights reserved. MIT license.
class ErrorEvent extends Event {
#message: string;
#filename: string;
#lineno: number;
#colno: number;
// deno-lint-ignore no-explicit-any
#error: any;
get message(): string {
return this.#message;
}
get filename(): string {
return this.#filename;
}
get lineno(): number {
return this.#lineno;
}
get colno(): number {
return this.#colno;
}
// deno-lint-ignore no-explicit-any
get error(): any {
return this.#error;
}
constructor(type: string, eventInitDict: ErrorEventInit = {}) {
super(type, eventInitDict);
const { message = "error", filename = "", lineno = 0, colno = 0, error } =
eventInitDict;
this.#message = message;
this.#filename = filename;
this.#lineno = lineno;
this.#colno = colno;
this.#error = error;
}
}
if (!("ErrorEvent" in globalThis)) {
Object.defineProperty(globalThis, "ErrorEvent", {
value: ErrorEvent,
writable: true,
enumerable: false,
configurable: true,
});
}
if (!("ReadableStream" in globalThis) || !("TransformStream" in globalThis)) {
(async () => {
const { ReadableStream, TransformStream } = await import("node:stream/web");
Object.defineProperties(globalThis, {
"ReadableStream": {
value: ReadableStream,
writable: true,
enumerable: false,
configurable: true,
},
"TransformStream": {
value: TransformStream,
writable: true,
enumerable: false,
configurable: true,
},
});
})();
}