Apply more let/const transforms.

This commit is contained in:
John-David Dalton
2017-01-08 23:38:19 -08:00
parent ca9e6fa087
commit 4d0c15b49e
115 changed files with 621 additions and 613 deletions

View File

@@ -2,22 +2,22 @@ import isObject from './isObject.js';
import isSymbol from './isSymbol.js';
/** Used as references for various `Number` constants. */
var NAN = 0 / 0;
const NAN = 0 / 0;
/** Used to match leading and trailing whitespace. */
var reTrim = /^\s+|\s+$/g;
const reTrim = /^\s+|\s+$/g;
/** Used to detect bad signed hexadecimal string values. */
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
const reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
/** Used to detect binary string values. */
var reIsBinary = /^0b[01]+$/i;
const reIsBinary = /^0b[01]+$/i;
/** Used to detect octal string values. */
var reIsOctal = /^0o[0-7]+$/i;
const reIsOctal = /^0o[0-7]+$/i;
/** Built-in method references without a dependency on `root`. */
var freeParseInt = parseInt;
const freeParseInt = parseInt;
/**
* Converts `value` to a number.
@@ -50,14 +50,14 @@ function toNumber(value) {
return NAN;
}
if (isObject(value)) {
var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
const other = typeof value.valueOf == 'function' ? value.valueOf() : value;
value = isObject(other) ? `${ other }` : other;
}
if (typeof value != 'string') {
return value === 0 ? value : +value;
}
value = value.replace(reTrim, '');
var isBinary = reIsBinary.test(value);
const isBinary = reIsBinary.test(value);
return (isBinary || reIsOctal.test(value))
? freeParseInt(value.slice(2), isBinary ? 2 : 8)
: (reIsBadHex.test(value) ? NAN : +value);