rich-domain
Version:
This package provide utils file and interfaces to assistant build a complex application with domain driving design
24 lines • 1.15 kB
TypeScript
/**
* @description Subtracts one number (`valueB`) from another (`valueA`) with optional precision adjustment.
* Handles edge cases where inputs are not valid numbers by normalizing the values or returning defaults.
*
* @param valueA The first value (minuend). Can be a number or a value convertible to a number.
* @param valueB The second value (subtrahend). Can be a number or a value convertible to a number.
* @param precision The number of decimal places to apply to the result. Defaults to 5.
*
* @returns The result of the subtraction, normalized and adjusted to the specified precision.
* Returns `0` if both inputs are `NaN`. If one of the inputs is invalid, the valid input is returned
* (or negated if the second value is `NaN`).
*
* @example
* ```typescript
* Subtract(10, 2); // Returns 8
* Subtract(10, "3.5", 2); // Returns 6.50
* Subtract(NaN, 5); // Returns -5
* Subtract(10, NaN); // Returns 10
* Subtract(NaN, NaN); // Returns 0
* ```
*/
export declare const Subtract: (valueA: number, valueB: number, precision?: number) => number;
export default Subtract;
//# sourceMappingURL=subtract-number.util.d.ts.map