hkt-toolbelt
Version:
Functional and composable type utilities
22 lines (21 loc) • 615 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.compare = void 0;
/**
* Given two natural numbers, return their comparison result as -1, 0, or 1.
*
* -1 if `a` is less than `b`, 1 if `a` is greater than `b`, and 0 if `a` is
* equal to `b`.
*
* @param {number} a - The first natural number to compare.
* @param {number} b - The second natural number to compare.
*
* @example
* ```ts
* import { NaturalNumber } from "hkt-toolbelt";
*
* const result = NaturalNumber.compare(2)(3)
* // ^? -1
* ```
*/
exports.compare = ((a) => (b) => a < b ? -1 : a > b ? 1 : 0);