...
1 package gojs
2
3 import (
4 "github.com/tetratelabs/wazero/internal/gojs/config"
5 "github.com/tetratelabs/wazero/internal/gojs/goos"
6 )
7
8
9 func newJsGlobal(config *config.Config) *jsVal {
10 var fetchProperty interface{} = goos.Undefined
11 proc := &processState{
12 cwd: config.Workdir,
13 umask: config.Umask,
14 }
15
16 return newJsVal(goos.RefValueGlobal, "global").
17 addProperties(map[string]interface{}{
18 "Object": objectConstructor,
19 "Array": arrayConstructor,
20 "crypto": jsCrypto,
21 "Uint8Array": uint8ArrayConstructor,
22 "fetch": fetchProperty,
23 "process": newJsProcess(proc),
24 "fs": newJsFs(proc),
25 "Date": jsDateConstructor,
26 })
27 }
28
29 var (
30
31
32
33
34
35
36
37 objectConstructor = newJsVal(goos.RefObjectConstructor, "Object")
38
39
40
41 arrayConstructor = newJsVal(goos.RefArrayConstructor, "Array")
42
43
44
45
46
47 uint8ArrayConstructor = newJsVal(goos.RefUint8ArrayConstructor, "Uint8Array")
48 )
49
View as plain text