@discipl/law-reg
Version:
Discipl Law and Regulation Compliance Library
43 lines (32 loc) • 875 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.BigUtil = void 0;
class BigUtil {
static genericOp(a, b, functionName, fallbackFunction, commutativeFunctionName = functionName) {
if (typeof a === 'undefined' || typeof b === 'undefined') {
return undefined;
}
if (a[functionName]) {
return a[functionName](b);
}
if (b[commutativeFunctionName]) {
return b[commutativeFunctionName](a);
}
return fallbackFunction();
}
static add(a, b) {
return this.genericOp(a, b, 'plus', () => a + b);
}
static multiply(a, b) {
return this.genericOp(a, b, 'times', () => a * b);
}
static equal(a, b) {
return this.genericOp(a, b, 'eq', () => a === b);
}
static lessThan(a, b) {
return this.genericOp(a, b, 'lt', () => a < b, 'gt');
}
}
exports.BigUtil = BigUtil;