mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 09:27:49 +00:00
Apply more let/const transforms.
This commit is contained in:
@@ -3,7 +3,7 @@ import toNumber from './toNumber.js';
|
||||
import toString from './toString.js';
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
var nativeMin = Math.min;
|
||||
const nativeMin = Math.min;
|
||||
|
||||
/**
|
||||
* Creates a function like `_.round`.
|
||||
@@ -13,15 +13,15 @@ var nativeMin = Math.min;
|
||||
* @returns {Function} Returns the new round function.
|
||||
*/
|
||||
function createRound(methodName) {
|
||||
var func = Math[methodName];
|
||||
const func = Math[methodName];
|
||||
return (number, precision) => {
|
||||
number = toNumber(number);
|
||||
precision = precision == null ? 0 : nativeMin(toInteger(precision), 292);
|
||||
if (precision) {
|
||||
// Shift with exponential notation to avoid floating-point issues.
|
||||
// See [MDN](https://mdn.io/round#Examples) for more details.
|
||||
var pair = `${ toString(number) }e`.split('e'),
|
||||
value = func(`${ pair[0] }e${ +pair[1] + precision }`);
|
||||
let pair = `${ toString(number) }e`.split('e');
|
||||
const value = func(`${ pair[0] }e${ +pair[1] + precision }`);
|
||||
|
||||
pair = `${ toString(value) }e`.split('e');
|
||||
return +`${ pair[0] }e${ +pair[1] - precision }`;
|
||||
|
||||
Reference in New Issue
Block a user