forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcaml_sys.js
107 lines (94 loc) · 2.23 KB
/
caml_sys.js
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
'use strict';
function caml_sys_getenv(s) {
if (typeof process === "undefined" || process.env === undefined) {
throw {
RE_EXN_ID: "Not_found",
Error: new Error()
};
}
var x = process.env[s];
if (x !== undefined) {
return x;
}
throw {
RE_EXN_ID: "Not_found",
Error: new Error()
};
}
var os_type = (function(_){
if(typeof process !== 'undefined' && process.platform === 'win32'){
return "Win32"
}
else {
return "Unix"
}
});
function caml_sys_time(param) {
if (typeof process === "undefined" || process.uptime === undefined) {
return -1;
} else {
return process.uptime();
}
}
function caml_sys_random_seed(param) {
return [((Date.now() | 0) ^ 4294967295) * Math.random() | 0];
}
function caml_sys_system_command(_cmd) {
return 127;
}
var caml_sys_getcwd = (function(param){
if (typeof process === "undefined" || process.cwd === undefined){
return "/"
}
return process.cwd()
});
function caml_sys_get_argv(param) {
if (typeof process === "undefined") {
return [
"",
[""]
];
}
var argv = process.argv;
if (argv == null) {
return [
"",
[""]
];
} else {
return [
argv[0],
argv
];
}
}
function caml_sys_exit(exit_code) {
if (typeof process !== "undefined") {
return process.exit(exit_code);
}
}
function caml_sys_is_directory(_s) {
throw {
RE_EXN_ID: "Failure",
_1: "caml_sys_is_directory not implemented",
Error: new Error()
};
}
function caml_sys_file_exists(_s) {
throw {
RE_EXN_ID: "Failure",
_1: "caml_sys_file_exists not implemented",
Error: new Error()
};
}
exports.caml_sys_getenv = caml_sys_getenv;
exports.caml_sys_time = caml_sys_time;
exports.os_type = os_type;
exports.caml_sys_random_seed = caml_sys_random_seed;
exports.caml_sys_system_command = caml_sys_system_command;
exports.caml_sys_getcwd = caml_sys_getcwd;
exports.caml_sys_get_argv = caml_sys_get_argv;
exports.caml_sys_exit = caml_sys_exit;
exports.caml_sys_is_directory = caml_sys_is_directory;
exports.caml_sys_file_exists = caml_sys_file_exists;
/* No side effect */