mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 18:17:48 +00:00
Make _.parseInt work as a callback to _.map.
This commit is contained in:
21
lodash.js
21
lodash.js
@@ -8854,13 +8854,20 @@
|
|||||||
* _.parseInt('08');
|
* _.parseInt('08');
|
||||||
* // => 8
|
* // => 8
|
||||||
*/
|
*/
|
||||||
var parseInt = nativeParseInt(whitespace + '08') == 8 ? nativeParseInt : function(value, radix) {
|
function parseInt(value, radix, guard) {
|
||||||
// Firefox < 21 and Opera < 15 follow ES3 for `parseInt` and
|
return nativeParseInt(value, guard ? 0 : radix);
|
||||||
// Chrome fails to trim leading <BOM> whitespace characters.
|
}
|
||||||
// See https://code.google.com/p/v8/issues/detail?id=3109
|
// fallback for environments with pre-ES5 implementations
|
||||||
value = trim(value);
|
if (nativeParseInt(whitespace + '08') != 8) {
|
||||||
return nativeParseInt(value, +radix || (reHexPrefix.test(value) ? 16 : 10));
|
parseInt = function(value, radix, guard) {
|
||||||
};
|
// Firefox < 21 and Opera < 15 follow ES3 for `parseInt` and
|
||||||
|
// Chrome fails to trim leading <BOM> whitespace characters.
|
||||||
|
// See https://code.google.com/p/v8/issues/detail?id=3109
|
||||||
|
value = trim(value);
|
||||||
|
radix = guard ? 0 : +radix;
|
||||||
|
return nativeParseInt(value, radix || (reHexPrefix.test(value) ? 16 : 10));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a "_.pluck" style function which returns the `key` value of a
|
* Creates a "_.pluck" style function which returns the `key` value of a
|
||||||
|
|||||||
Reference in New Issue
Block a user