source:
node_modules/es-toolkit/dist/math/round.mjs
| Last change on this file was a762898, checked in by , 5 months ago | |
|---|---|
|
|
| File size: 268 bytes | |
| Line | |
|---|---|
| 1 | function round(value, precision = 0) { |
| 2 | if (!Number.isInteger(precision)) { |
| 3 | throw new Error('Precision must be an integer.'); |
| 4 | } |
| 5 | const multiplier = Math.pow(10, precision); |
| 6 | return Math.round(value * multiplier) / multiplier; |
| 7 | } |
| 8 | |
| 9 | export { round }; |
Note:
See TracBrowser
for help on using the repository browser.
