UNPKG

hkt-toolbelt

Version:

Functional and composable type utilities

20 lines (19 loc) 508 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.subtractBy = void 0; /** * Given two natural numbers, subtract the first number from the second. The * result is capped at zero. * * @param {number} a - The first number. * @param {number} b - The second number. * * @example * ```ts * import { NaturalNumber } from "hkt-toolbelt"; * * const result = NaturalNumber.subtractBy(2)(3) * // ^? 1 * ``` */ exports.subtractBy = ((a) => (b) => a > b ? 0 : b - a);