@rescript/std
Version:
The motiviation of this repo is that when ReScript users want to share their library with JS users, the JS users don't need have ReScript toolchain installed, this makes sharing code with JS users easier (more details on that topic can be found in our [Ex
60 lines (50 loc) • 1.01 kB
JavaScript
import * as Caml_exceptions from "./caml_exceptions.js";
function is_val(l) {
return l.LAZY_DONE;
}
var Undefined = /* @__PURE__ */Caml_exceptions.create("CamlinternalLazy.Undefined");
function forward_with_closure(blk, closure) {
var result = closure();
blk.VAL = result;
blk.LAZY_DONE = true;
return result;
}
function raise_undefined() {
throw {
RE_EXN_ID: Undefined,
Error: new Error()
};
}
function force(lzv) {
if (lzv.LAZY_DONE) {
return lzv.VAL;
} else {
var closure = lzv.VAL;
lzv.VAL = raise_undefined;
try {
return forward_with_closure(lzv, closure);
}
catch (e){
lzv.VAL = (function () {
throw e;
});
throw e;
}
}
}
function force_val(lzv) {
if (lzv.LAZY_DONE) {
return lzv.VAL;
} else {
var closure = lzv.VAL;
lzv.VAL = raise_undefined;
return forward_with_closure(lzv, closure);
}
}
export {
Undefined ,
force ,
force_val ,
is_val ,
}
/* No side effect */