UNPKG

hkt-toolbelt

Version:

Functional and composable type utilities

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