time-to-botec/squiggle/node_modules/@rescript/std/lib/js/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

150 lines
2.7 KiB
JavaScript

'use strict';
var Curry = require("./curry.js");
var Caml_option = require("./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));
}
exports.keepU = keepU;
exports.keep = keep;
exports.forEachU = forEachU;
exports.forEach = forEach;
exports.getExn = getExn;
exports.mapWithDefaultU = mapWithDefaultU;
exports.mapWithDefault = mapWithDefault;
exports.mapU = mapU;
exports.map = map;
exports.flatMapU = flatMapU;
exports.flatMap = flatMap;
exports.getWithDefault = getWithDefault;
exports.orElse = orElse;
exports.isSome = isSome;
exports.isNone = isNone;
exports.eqU = eqU;
exports.eq = eq;
exports.cmpU = cmpU;
exports.cmp = cmp;
/* No side effect */