Idris-dev/jsrts/Runtime-common.js
2017-05-25 15:04:46 +08:00

22 lines
617 B
JavaScript

const $JSRTS = {
throw: function (x) {
throw x;
},
Lazy: function (e) {
this.js_idris_lazy_calc = e;
this.js_idris_lazy_val = void 0;
},
force: function (x) {
if (x === undefined || x.js_idris_lazy_calc === undefined) {
return x
} else {
if (x.js_idris_lazy_val === undefined) {
x.js_idris_lazy_val = x.js_idris_lazy_calc()
}
return x.js_idris_lazy_val
}
},
prim_strSubstr: function (offset, len, str) {
return str.substr(Math.max(0, offset), Math.max(0, len))
}
};