rich-domain
Version:
This package provide utils file and interfaces to assistant build a complex application with domain driving design
23 lines • 1.04 kB
TypeScript
/**
* @description Adds two numbers (`valueA` and `valueB`) 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 to add. Can be a number or a value convertible to a number.
* @param valueB The second value to add. 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 addition, 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.
*
* @example
* ```typescript
* Sum(10, 5); // Returns 15
* Sum(10, "3.5", 2); // Returns 13.50
* Sum(NaN, 5); // Returns 5
* Sum(10, NaN); // Returns 10
* Sum(NaN, NaN); // Returns 0
* ```
*/
export declare const Sum: (valueA: number, valueB: number, precision?: number) => number;
export default Sum;
//# sourceMappingURL=sum-number.util.d.ts.map