time-to-botec/squiggle/node_modules/@rescript/std/lib/es6/belt_Option.js
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00

152 lines
2.4 KiB
JavaScript

import * as Curry from "./curry.js";
import * as Caml_option from "./caml_option.js";
function keepU(opt, p) {
if (opt !== undefined && p(Caml_option.valFromOption(opt))) {
return opt;
}
}
function keep(opt, p) {
return keepU(opt, Curry.__1(p));
}
function forEachU(opt, f) {
if (opt !== undefined) {
return f(Caml_option.valFromOption(opt));
}
}
function forEach(opt, f) {
forEachU(opt, Curry.__1(f));
}
function getExn(x) {
if (x !== undefined) {
return Caml_option.valFromOption(x);
}
throw {
RE_EXN_ID: "Not_found",
Error: new Error()
};
}
function mapWithDefaultU(opt, $$default, f) {
if (opt !== undefined) {
return f(Caml_option.valFromOption(opt));
} else {
return $$default;
}
}
function mapWithDefault(opt, $$default, f) {
return mapWithDefaultU(opt, $$default, Curry.__1(f));
}
function mapU(opt, f) {
if (opt !== undefined) {
return Caml_option.some(f(Caml_option.valFromOption(opt)));
}
}
function map(opt, f) {
return mapU(opt, Curry.__1(f));
}
function flatMapU(opt, f) {
if (opt !== undefined) {
return f(Caml_option.valFromOption(opt));
}
}
function flatMap(opt, f) {
return flatMapU(opt, Curry.__1(f));
}
function getWithDefault(opt, $$default) {
if (opt !== undefined) {
return Caml_option.valFromOption(opt);
} else {
return $$default;
}
}
function orElse(opt, other) {
if (opt !== undefined) {
return opt;
} else {
return other;
}
}
function isSome(param) {
return param !== undefined;
}
function isNone(x) {
return x === undefined;
}
function eqU(a, b, f) {
if (a !== undefined) {
if (b !== undefined) {
return f(Caml_option.valFromOption(a), Caml_option.valFromOption(b));
} else {
return false;
}
} else {
return b === undefined;
}
}
function eq(a, b, f) {
return eqU(a, b, Curry.__2(f));
}
function cmpU(a, b, f) {
if (a !== undefined) {
if (b !== undefined) {
return f(Caml_option.valFromOption(a), Caml_option.valFromOption(b));
} else {
return 1;
}
} else if (b !== undefined) {
return -1;
} else {
return 0;
}
}
function cmp(a, b, f) {
return cmpU(a, b, Curry.__2(f));
}
export {
keepU ,
keep ,
forEachU ,
forEach ,
getExn ,
mapWithDefaultU ,
mapWithDefault ,
mapU ,
map ,
flatMapU ,
flatMap ,
getWithDefault ,
orElse ,
isSome ,
isNone ,
eqU ,
eq ,
cmpU ,
cmp ,
}
/* No side effect */