-
Notifications
You must be signed in to change notification settings - Fork 465
/
Copy pathjs_option.js
104 lines (87 loc) · 1.8 KB
/
js_option.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
'use strict';
let Js_exn = require("./js_exn.js");
let Caml_option = require("./caml_option.js");
function some(x) {
return Caml_option.some(x);
}
function isSome(x) {
return x !== undefined;
}
function isSomeValue(eq, v, x) {
if (x !== undefined) {
return eq(v, Caml_option.valFromOption(x));
} else {
return false;
}
}
function isNone(x) {
return x === undefined;
}
function getExn(x) {
if (x !== undefined) {
return Caml_option.valFromOption(x);
} else {
return Js_exn.raiseError("getExn");
}
}
function equal(eq, a, b) {
if (a !== undefined) {
if (b !== undefined) {
return eq(Caml_option.valFromOption(a), Caml_option.valFromOption(b));
} else {
return false;
}
} else {
return b === undefined;
}
}
function andThen(f, x) {
if (x !== undefined) {
return f(Caml_option.valFromOption(x));
}
}
function map(f, x) {
if (x !== undefined) {
return Caml_option.some(f(Caml_option.valFromOption(x)));
}
}
function getWithDefault(a, x) {
if (x !== undefined) {
return Caml_option.valFromOption(x);
} else {
return a;
}
}
function filter(f, x) {
if (x === undefined) {
return;
}
let x$1 = Caml_option.valFromOption(x);
if (f(x$1)) {
return Caml_option.some(x$1);
}
}
function firstSome(a, b) {
if (a !== undefined) {
return a;
} else if (b !== undefined) {
return b;
} else {
return;
}
}
let $$default = getWithDefault;
exports.some = some;
exports.isSome = isSome;
exports.isSomeValue = isSomeValue;
exports.isNone = isNone;
exports.getExn = getExn;
exports.equal = equal;
exports.andThen = andThen;
exports.map = map;
exports.getWithDefault = getWithDefault;
exports.default = $$default;
exports.__esModule = true;
exports.filter = filter;
exports.firstSome = firstSome;
/* No side effect */