forked from rescript-lang/rescript-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCore__Nullable.mjs
81 lines (68 loc) · 1.54 KB
/
Core__Nullable.mjs
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
// Generated by ReScript, PLEASE EDIT WITH CARE
import * as Curry from "rescript/lib/es6/curry.js";
import * as Caml_option from "rescript/lib/es6/caml_option.js";
import * as Core__Option from "./Core__Option.mjs";
function fromOption(option) {
if (option !== undefined) {
return Caml_option.valFromOption(option);
}
}
function equal(a, b, eq) {
return Core__Option.equal((a == null) ? undefined : Caml_option.some(a), (b == null) ? undefined : Caml_option.some(b), eq);
}
function compare(a, b, cmp) {
return Core__Option.compare((a == null) ? undefined : Caml_option.some(a), (b == null) ? undefined : Caml_option.some(b), cmp);
}
function getOr(value, $$default) {
if (value == null) {
return $$default;
} else {
return value;
}
}
function getExn(value) {
if (!(value == null)) {
return value;
}
throw {
RE_EXN_ID: "Invalid_argument",
_1: "Nullable.getExn: value is null or undefined",
Error: new Error()
};
}
function map(value, f) {
if (value == null) {
return value;
} else {
return Curry._1(f, value);
}
}
function mapOr(value, $$default, f) {
if (value == null) {
return $$default;
} else {
return Curry._1(f, value);
}
}
function flatMap(value, f) {
if (value == null) {
return value;
} else {
return Curry._1(f, value);
}
}
var getWithDefault = getOr;
var mapWithDefault = mapOr;
export {
equal ,
compare ,
fromOption ,
getOr ,
getWithDefault ,
getExn ,
map ,
mapOr ,
mapWithDefault ,
flatMap ,
}
/* No side effect */