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

87 lines
1.3 KiB
JavaScript

function isNested(x) {
return x.BS_PRIVATE_NESTED_SOME_NONE !== undefined;
}
function some(x) {
if (x === undefined) {
return {
BS_PRIVATE_NESTED_SOME_NONE: 0
};
} else if (x !== null && x.BS_PRIVATE_NESTED_SOME_NONE !== undefined) {
return {
BS_PRIVATE_NESTED_SOME_NONE: x.BS_PRIVATE_NESTED_SOME_NONE + 1 | 0
};
} else {
return x;
}
}
function nullable_to_opt(x) {
if (x == null) {
return ;
} else {
return some(x);
}
}
function undefined_to_opt(x) {
if (x === undefined) {
return ;
} else {
return some(x);
}
}
function null_to_opt(x) {
if (x === null) {
return ;
} else {
return some(x);
}
}
function valFromOption(x) {
if (!(x !== null && x.BS_PRIVATE_NESTED_SOME_NONE !== undefined)) {
return x;
}
var depth = x.BS_PRIVATE_NESTED_SOME_NONE;
if (depth === 0) {
return ;
} else {
return {
BS_PRIVATE_NESTED_SOME_NONE: depth - 1 | 0
};
}
}
function option_get(x) {
if (x === undefined) {
return ;
} else {
return valFromOption(x);
}
}
function option_unwrap(x) {
if (x !== undefined) {
return x.VAL;
} else {
return x;
}
}
export {
nullable_to_opt ,
undefined_to_opt ,
null_to_opt ,
valFromOption ,
some ,
isNested ,
option_get ,
option_unwrap ,
}
/* No side effect */