- Notifications
You must be signed in to change notification settings - Fork 670
/
Copy pathprocess.ts
50 lines (38 loc) · 1.05 KB
/
process.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
import{
DateasDate_binding,
performanceasperformance_binding
}from"bindings/dom";
import{
processasprocess_binding
}from"bindings/node";
exportnamespaceprocess{
// @ts-ignore: decorator
@lazyexportconstarch=sizeof<usize>()==4 ? "wasm32" : "wasm64";
// @ts-ignore: decorator
@lazyexportconstplatform="wasm";
// @ts-ignore: decorator
@lazyexportconstargv=lazyArgv();
// @ts-ignore: decorator
@lazyexportconstenv=lazyEnv();
// @ts-ignore: decorator
@lazyexportletexitCode=0;
exportfunctionexit(code: i32=exitCode): void{
process_binding.exit(code);
}
exportfunctiontime(): i64{
return<i64>Date_binding.now();
}
exportfunctionhrtime(): u64{
letnow=performance_binding.now();
letmillis=<u64>now;
letfraction=now-<f64>millis;
returnmillis*1000000+<u64>(fraction*1000000);
}
}
functionlazyArgv(): string[]{
returnprocess_binding.argv;
}
functionlazyEnv(): Map<string,string>{
// TODO: What about Node?
returnnewMap();
}