lbx-invoice
Version:
Provides functionality around generating invoices.
46 lines • 1.72 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BigNumberUtilities = void 0;
const bignumber_js_1 = require("bignumber.js");
/**
* Provides functionality around calculating with high precision.
*/
class BigNumberUtilities {
/**
* Creates a BigNumber from the provided input.
* @param value - The number value to create from.
* @returns A new BigNumber.
*/
static new(value) {
return new bignumber_js_1.BigNumber(value);
}
/**
* Precisely multiplies the given values.
* @param value1 - The first number to multiply.
* @param value2 - The second number to multiply.
* @returns The precise result as BigNumber.
*/
static multiply(value1, value2) {
return new bignumber_js_1.BigNumber(value1).multipliedBy(new bignumber_js_1.BigNumber(value2));
}
/**
* Precisely divides the first value by the second value.
* @param dividend - The value that will be divided.
* @param divisor - The value that divides the first value.
* @returns The precise result as BigNumber.
*/
static divide(dividend, divisor) {
return new bignumber_js_1.BigNumber(dividend).dividedBy(new bignumber_js_1.BigNumber(divisor));
}
/**
* Precisely adds the given values.
* @param value1 - The first number for the addition.
* @param value2 - The second number for the addition.
* @returns The precise result as BigNumber.
*/
static add(value1, value2) {
return new bignumber_js_1.BigNumber(value1).plus(new bignumber_js_1.BigNumber(value2));
}
}
exports.BigNumberUtilities = BigNumberUtilities;
//# sourceMappingURL=big-number.utilities.js.map