@dinero.js/calculator-number
Version:
Number calculator implementation for Dinero.js
21 lines (18 loc) • 475 B
JavaScript
import { ComparisonOperator } from '@dinero.js/core';
/**
* Compare two numbers.
*
* @param a - The first number to compare.
* @param b - The second number to compare.
*
* @returns Whether the two numbers are equal, or whether the first one is greater or less than the other.
*/
export var compare = function compare(a, b) {
if (a < b) {
return ComparisonOperator.LT;
}
if (a > b) {
return ComparisonOperator.GT;
}
return ComparisonOperator.EQ;
};