File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change 1
- if ( typeof window === 'undefined' ) {
2
- ! global . crypto && ( global . crypto = {
1
+ if ( typeof globalThis . navigator === 'undefined' ) {
2
+ ! globalThis . crypto && ( globalThis . crypto = {
3
3
async getRandomValues ( b ) {
4
4
const { randomFillSync } = await import ( 'crypto' ) ;
5
5
randomFillSync ( b ) ;
6
6
}
7
7
} ) ;
8
- ! global . performance && ( global . performance = {
8
+ ! globalThis . performance && ( globalThis . performance = {
9
9
now ( ) {
10
10
const [ sec , nsec ] = process . hrtime ( ) ;
11
11
return sec * 1000 + nsec / 1000000 ;
@@ -572,19 +572,18 @@ import pako from 'pako';
572
572
export async function init ( wasmPath ) {
573
573
const go = new Go ( ) ;
574
574
var buffer ;
575
- if ( typeof window === 'undefined' ) {
576
- global . excelize = { } ;
575
+ if ( typeof globalThis . navigator === 'undefined' ) {
576
+ globalThis . excelize = { } ;
577
577
const fs = await import ( 'fs' ) ;
578
578
buffer = pako . ungzip ( fs . readFileSync ( wasmPath ) ) ;
579
579
} else {
580
- window . excelize = { } ;
580
+ globalThis . excelize = { } ;
581
581
buffer = pako . ungzip ( await ( await fetch ( wasmPath ) ) . arrayBuffer ( ) ) ;
582
582
}
583
583
if ( buffer [ 0 ] === 0x1f && buffer [ 1 ] === 0x8b ) {
584
- buffer = pako . ungzip ( buffer ) ;
584
+ buffer = pako . ungzip ( buffer ) ;
585
585
}
586
586
const result = await WebAssembly . instantiate ( buffer , go . importObject ) ;
587
587
go . run ( result . instance ) ;
588
588
return excelize ;
589
589
} ;
590
-
You can’t perform that action at this time.
0 commit comments