time-to-botec/squiggle/node_modules/@rescript/std/lib/js/caml_option.js

85 lines
1.5 KiB
JavaScript
Raw Normal View History

'use strict';
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;
}
}
exports.nullable_to_opt = nullable_to_opt;
exports.undefined_to_opt = undefined_to_opt;
exports.null_to_opt = null_to_opt;
exports.valFromOption = valFromOption;
exports.some = some;
exports.isNested = isNested;
exports.option_get = option_get;
exports.option_unwrap = option_unwrap;
/* No side effect */