mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 08:07:50 +00:00
Bump to v4.16.0.
This commit is contained in:
11
parseInt.js
11
parseInt.js
@@ -1,12 +1,6 @@
|
||||
var root = require('./_root'),
|
||||
toString = require('./toString');
|
||||
|
||||
/** 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);
|
||||
}
|
||||
|
||||
module.exports = parseInt;
|
||||
|
||||
Reference in New Issue
Block a user