@ultipa-graph/ultipa-driver
Version:
NodeJS SDK for ultipa-server 5.2
46 lines • 1.33 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SafeBigInt = exports.SafeFloat = exports.SafeInt = exports.TypeSupport = void 0;
const types_1 = require("../../types/types");
var TypeSupport;
(function (TypeSupport) {
TypeSupport.list = true;
TypeSupport.map = false;
TypeSupport.set = true;
function NotSupport(type) {
let t = type;
throw new Error(`not support [${t}: ${types_1.UltipaPropertyType[t]}]`);
}
TypeSupport.NotSupport = NotSupport;
})(TypeSupport = exports.TypeSupport || (exports.TypeSupport = {}));
const SafeInt = (v) => {
if (v === "" || isNaN(+v)) {
v = "0";
}
return parseInt(v);
};
exports.SafeInt = SafeInt;
const SafeFloat = (v) => {
if (v === "" || isNaN(+v)) {
v = "0";
}
return parseFloat(v);
};
exports.SafeFloat = SafeFloat;
const SafeBigInt = (v) => {
if (v) {
if (typeof v == "number") {
v = v + "";
}
if (v === "" || isNaN(+v)) {
v = "0";
}
if (typeof v == "string" && v.includes(".")) {
let dot = v.indexOf(".");
v = v.substring(0, dot);
}
}
return BigInt(v);
};
exports.SafeBigInt = SafeBigInt;
//# sourceMappingURL=commont.js.map