UNPKG

remeda

Version:

A utility library for JavaScript and Typescript.

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