mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 23:57:49 +00:00
Bump to v4.16.0.
This commit is contained in:
11
parseInt.js
11
parseInt.js
@@ -1,12 +1,6 @@
|
||||
import root from './_root.js';
|
||||
import toString from './toString.js';
|
||||
|
||||
/** Used to match leading and trailing whitespace. */
|
||||
var reTrim = /^\s+|\s+$/g;
|
||||
|
||||
/** Used to detect hexadecimal string values. */
|
||||
var reHasHexPrefix = /^0x/i;
|
||||
|
||||
/* Built-in method references for those with the same name as other `lodash` methods. */
|
||||
var nativeParseInt = root.parseInt;
|
||||
|
||||
@@ -35,15 +29,12 @@ var nativeParseInt = root.parseInt;
|
||||
* // => [6, 8, 10]
|
||||
*/
|
||||
function parseInt(string, radix, guard) {
|
||||
// Chrome fails to trim leading <BOM> whitespace characters.
|
||||
// See https://bugs.chromium.org/p/v8/issues/detail?id=3109 for more details.
|
||||
if (guard || radix == null) {
|
||||
radix = 0;
|
||||
} else if (radix) {
|
||||
radix = +radix;
|
||||
}
|
||||
string = toString(string).replace(reTrim, '');
|
||||
return nativeParseInt(string, radix || (reHasHexPrefix.test(string) ? 16 : 10));
|
||||
return nativeParseInt(toString(string), radix || 0);
|
||||
}
|
||||
|
||||
export default parseInt;
|
||||
|
||||
Reference in New Issue
Block a user