UNPKG

remeda

Version:

A utility library for JavaScript and Typescript.

1 lines 1.63 kB
{"version":3,"file":"subtract.cjs","names":["purry"],"sources":["../src/subtract.ts"],"sourcesContent":["import { purry } from \"./purry\";\n\n/**\n * Subtracts two numbers.\n *\n * @param value - The number.\n * @param subtrahend - The number to subtract from the value.\n * @signature\n * R.subtract(value, subtrahend);\n * @example\n * R.subtract(10, 5) // => 5\n * R.subtract(10, -5) // => 15\n * R.reduce([1, 2, 3, 4], R.subtract, 20) // => 10\n * @dataFirst\n * @category Number\n */\nexport function subtract(value: bigint, subtrahend: bigint): bigint;\nexport function subtract(value: number, subtrahend: number): number;\n\n/**\n * Subtracts two numbers.\n *\n * @param subtrahend - The number to subtract from the value.\n * @signature\n * R.subtract(subtrahend)(value);\n * @example\n * R.subtract(5)(10) // => 5\n * R.subtract(-5)(10) // => 15\n * R.map([1, 2, 3, 4], R.subtract(1)) // => [0, 1, 2, 3]\n * @dataLast\n * @category Number\n */\nexport function subtract(subtrahend: bigint): (value: bigint) => bigint;\nexport function subtract(subtrahend: number): (value: number) => number;\n\nexport function subtract(...args: ReadonlyArray<unknown>): unknown {\n return purry(subtractImplementation, args);\n}\n\n// The implementation only uses `number` types, but that's just because it's\n// hard to tell typescript that both value and subtrahend would be of the same\n// type.\nconst subtractImplementation = (value: number, subtrahend: number): number =>\n value - subtrahend;\n"],"mappings":"wCAmCA,SAAgB,EAAS,GAAG,EAAuC,CACjE,OAAOA,EAAAA,EAAM,EAAwB,EAAK,CAM5C,MAAM,GAA0B,EAAe,IAC7C,EAAQ"}