File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -29,22 +29,23 @@ class CustomEventPolyfill extends Event {
29
29
}
30
30
}
31
31
32
- global . CustomEvent = CustomEventPolyfill
32
+ global . CustomEvent = global . CustomEvent ?? CustomEventPolyfill
33
33
34
- global . AbortSignal . timeout = ( ms ) => {
34
+ global . AbortSignal . timeout = global . AbortSignal . timeout ?? ( ( ms ) => {
35
35
const controller = new AbortController ( )
36
36
setTimeout ( ( ) => {
37
37
controller . abort ( new Error ( 'Aborted' ) )
38
38
} , ms )
39
- }
40
- global . AbortSignal . prototype . throwIfAborted = ( ) => {
39
+ } )
40
+ global . AbortSignal . prototype . throwIfAborted = global . AbortSignal . prototype . throwIfAborted ?? ( ( ) => {
41
41
if ( this . aborted ) {
42
42
throw new Error ( 'Aborted' )
43
43
}
44
- }
44
+ } )
45
45
46
- global . Buffer = Buffer
47
- global . crypto . subtle = new Crypto ( ) . subtle
46
+ global . Buffer = global . Buffer ?? Buffer
47
+ global . crypto = global . crypto ?? { }
48
+ global . crypto . subtle = global . crypto . subtle ?? new Crypto ( ) . subtle
48
49
49
50
/**
50
51
* Polyfill missing ES2024 promise methods
You can’t perform that action at this time.
0 commit comments