mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 15:57:48 +00:00
Bump to v4.16.0.
This commit is contained in:
11
parseInt.js
11
parseInt.js
@@ -1,11 +1,5 @@
|
||||
define(['./_root', './toString'], function(root, 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;
|
||||
|
||||
@@ -34,15 +28,12 @@ define(['./_root', './toString'], function(root, toString) {
|
||||
* // => [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);
|
||||
}
|
||||
|
||||
return parseInt;
|
||||
|
||||
Reference in New Issue
Block a user