mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 01:57:50 +00:00
Cleanup createRound.
This commit is contained in:
@@ -2,9 +2,6 @@ import toInteger from './toInteger.js';
|
|||||||
import toNumber from './toNumber.js';
|
import toNumber from './toNumber.js';
|
||||||
import toString from './toString.js';
|
import toString from './toString.js';
|
||||||
|
|
||||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
||||||
const nativeMin = Math.min;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a function like `round`.
|
* Creates a function like `round`.
|
||||||
*
|
*
|
||||||
@@ -16,7 +13,7 @@ function createRound(methodName) {
|
|||||||
const func = Math[methodName];
|
const func = Math[methodName];
|
||||||
return (number, precision) => {
|
return (number, precision) => {
|
||||||
number = toNumber(number);
|
number = toNumber(number);
|
||||||
precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
|
precision = precision == null ? 0 : Math.min(toInteger(precision), 292);
|
||||||
if (precision) {
|
if (precision) {
|
||||||
// Shift with exponential notation to avoid floating-point issues.
|
// Shift with exponential notation to avoid floating-point issues.
|
||||||
// See [MDN](https://mdn.io/round#Examples) for more details.
|
// See [MDN](https://mdn.io/round#Examples) for more details.
|
||||||
|
|||||||
Reference in New Issue
Block a user