UNPKG

remeda

Version:

A utility library for JavaScript and Typescript.

1 lines 1.83 kB
{"version":3,"file":"floor.cjs","names":["purry","withPrecision"],"sources":["../src/floor.ts"],"sourcesContent":["import { withPrecision } from \"./internal/withPrecision\";\nimport { purry } from \"./purry\";\n\n/**\n * Rounds down a given number to a specific precision.\n * If you'd like to round down to an integer (i.e. use this function with constant `precision === 0`),\n * use `Math.floor` instead, as it won't incur the additional library overhead.\n *\n * @param value - The number to round down.\n * @param precision - The precision to round down to. Must be an integer between -15 and 15.\n * @signature\n * R.floor(value, precision);\n * @example\n * R.floor(123.9876, 3) // => 123.987\n * R.floor(483.22243, 1) // => 483.2\n * R.floor(8541, -1) // => 8540\n * R.floor(456789, -3) // => 456000\n * @dataFirst\n * @category Number\n */\nexport function floor(value: number, precision: number): number;\n\n/**\n * Rounds down a given number to a specific precision.\n * If you'd like to round down to an integer (i.e. use this function with constant `precision === 0`),\n * use `Math.floor` instead, as it won't incur the additional library overhead.\n *\n * @param precision - The precision to round down to. Must be an integer between -15 and 15.\n * @signature\n * R.floor(precision)(value);\n * @example\n * R.floor(3)(123.9876) // => 123.987\n * R.floor(1)(483.22243) // => 483.2\n * R.floor(-1)(8541) // => 8540\n * R.floor(-3)(456789) // => 456000\n * @dataLast\n * @category Number\n */\nexport function floor(precision: number): (value: number) => number;\n\nexport function floor(...args: readonly unknown[]): unknown {\n return purry(withPrecision(Math.floor), args);\n}\n"],"mappings":"kFAwCA,SAAgB,EAAM,GAAG,EAAmC,CAC1D,OAAOA,EAAAA,EAAMC,EAAAA,EAAc,KAAK,MAAM,CAAE,EAAK"}