UNPKG

@node-dlc/core

Version:
59 lines 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.toBigInt = exports.BigIntMath = void 0; class BigIntMath { static max(...values) { if (values.length === 0) { return null; } if (values.length === 1) { return values[0]; } let max = values[0]; for (let i = 1; i < values.length; i++) { if (values[i] > max) { max = values[i]; } } return max; } static min(...values) { if (values.length === 0) { return null; } if (values.length === 1) { return values[0]; } let min = values[0]; for (let i = 1; i < values.length; i++) { if (values[i] < min) { min = values[i]; } } return min; } static sign(value) { if (value > BigInt(0)) { return BigInt(1); } if (value < BigInt(0)) { return BigInt(-1); } return BigInt(0); } static abs(value) { if (this.sign(value) === BigInt(-1)) { return -value; } return value; } static clamp(min, val, max) { return this.max(min, this.min(val, max)); } } exports.BigIntMath = BigIntMath; function toBigInt(num) { return BigInt(num.integerValue().toString()); } exports.toBigInt = toBigInt; //# sourceMappingURL=BigIntUtils.js.map