forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs_types.js
75 lines (70 loc) · 1.51 KB
/
js_types.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
'use strict';
function classify(x) {
var ty = typeof x;
if (ty === "undefined") {
return "JSUndefined";
} else if (x === null) {
return "JSNull";
} else if (ty === "number") {
return {
TAG: "JSNumber",
_0: x
};
} else if (ty === "bigint") {
return {
TAG: "JSBigInt",
_0: x
};
} else if (ty === "string") {
return {
TAG: "JSString",
_0: x
};
} else if (ty === "boolean") {
if (x === true) {
return "JSTrue";
} else {
return "JSFalse";
}
} else if (ty === "symbol") {
return {
TAG: "JSSymbol",
_0: x
};
} else if (ty === "function") {
return {
TAG: "JSFunction",
_0: x
};
} else {
return {
TAG: "JSObject",
_0: x
};
}
}
function test(x, v) {
switch (v) {
case "Undefined" :
return typeof x === "undefined";
case "Null" :
return x === null;
case "Boolean" :
return typeof x === "boolean";
case "Number" :
return typeof x === "number";
case "String" :
return typeof x === "string";
case "Function" :
return typeof x === "function";
case "Object" :
return typeof x === "object";
case "Symbol" :
return typeof x === "symbol";
case "BigInt" :
return typeof x === "bigint";
}
}
exports.test = test;
exports.classify = classify;
/* No side effect */