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

132 lines
2.2 KiB
JavaScript

'use strict';
var Caml = require("./caml.js");
var Caml_format = require("./caml_format.js");
function err_not_sv(i) {
return Caml_format.format_int("%X", i) + " is not an Unicode scalar value";
}
function err_not_latin1(u) {
return "U+" + (Caml_format.format_int("%04X", u) + " is not a latin1 character");
}
function succ(u) {
if (u === 55295) {
return 57344;
}
if (u === 1114111) {
throw {
RE_EXN_ID: "Invalid_argument",
_1: "U+10FFFF has no successor",
Error: new Error()
};
}
return u + 1 | 0;
}
function pred(u) {
if (u === 57344) {
return 55295;
}
if (u === 0) {
throw {
RE_EXN_ID: "Invalid_argument",
_1: "U+0000 has no predecessor",
Error: new Error()
};
}
return u - 1 | 0;
}
function is_valid(i) {
if (0 <= i && i <= 55295) {
return true;
} else if (57344 <= i) {
return i <= 1114111;
} else {
return false;
}
}
function of_int(i) {
if (is_valid(i)) {
return i;
}
var s = err_not_sv(i);
throw {
RE_EXN_ID: "Invalid_argument",
_1: s,
Error: new Error()
};
}
function is_char(u) {
return u < 256;
}
function of_char(c) {
return c;
}
function to_char(u) {
if (u <= 255) {
return u;
}
var s = err_not_latin1(u);
throw {
RE_EXN_ID: "Invalid_argument",
_1: s,
Error: new Error()
};
}
function unsafe_to_char(prim) {
return prim;
}
function equal(prim0, prim1) {
return prim0 === prim1;
}
var compare = Caml.int_compare;
function hash(prim) {
return prim;
}
var min = 0;
var max = 1114111;
var bom = 65279;
var rep = 65533;
function unsafe_of_int(prim) {
return prim;
}
function to_int(prim) {
return prim;
}
exports.min = min;
exports.max = max;
exports.bom = bom;
exports.rep = rep;
exports.succ = succ;
exports.pred = pred;
exports.is_valid = is_valid;
exports.of_int = of_int;
exports.unsafe_of_int = unsafe_of_int;
exports.to_int = to_int;
exports.is_char = is_char;
exports.of_char = of_char;
exports.to_char = to_char;
exports.unsafe_to_char = unsafe_to_char;
exports.equal = equal;
exports.compare = compare;
exports.hash = hash;
/* No side effect */