mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 11:27:50 +00:00
Add _.parseInt.
Former-commit-id: 0c0f10af3dc50a4d1b684523f19d02e423d738f5
This commit is contained in:
37
dist/lodash.compat.js
vendored
37
dist/lodash.compat.js
vendored
@@ -170,6 +170,7 @@
|
||||
nativeKeys = reNative.test(nativeKeys = Object.keys) && nativeKeys,
|
||||
nativeMax = Math.max,
|
||||
nativeMin = Math.min,
|
||||
nativeParseInt = context.parseInt,
|
||||
nativeRandom = Math.random;
|
||||
|
||||
/** Detect various environments */
|
||||
@@ -289,13 +290,13 @@
|
||||
* `union`, `uniq`, `unshift`, `values`, `where`, `without`, `wrap`, and `zip`
|
||||
*
|
||||
* The non-chainable wrapper functions are:
|
||||
* `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`, `identity`,
|
||||
* `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`,
|
||||
* `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`,
|
||||
* `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`,
|
||||
* `lastIndexOf`, `mixin`, `noConflict`, `pop`, `random`, `reduce`, `reduceRight`,
|
||||
* `result`, `shift`, `size`, `some`, `sortedIndex`, `template`, `unescape`,
|
||||
* `uniqueId`, and `value`
|
||||
* `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `has`,
|
||||
* `identity`, `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`,
|
||||
* `isElement`, `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`,
|
||||
* `isNull`, `isNumber`, `isObject`, `isPlainObject`, `isRegExp`, `isString`,
|
||||
* `isUndefined`, `join`, `lastIndexOf`, `mixin`, `noConflict`, `parseInt`,
|
||||
* `pop`, `random`, `reduce`, `reduceRight`, `result`, `shift`, `size`, `some`,
|
||||
* `sortedIndex`, `runInContext`, `template`, `unescape`, `uniqueId`, and `value`
|
||||
*
|
||||
* The wrapper functions `first` and `last` return wrapped values when `n` is
|
||||
* passed, otherwise they return unwrapped values.
|
||||
@@ -2108,6 +2109,27 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the given `value` into an integer of the specified `radix`.
|
||||
*
|
||||
* Note: This method avoids differences in ES3 and ES5 `parseInt`
|
||||
* implementations. See http://es5.github.com/#E.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Objects
|
||||
* @param {Mixed} value The value to parse.
|
||||
* @returns {Number} Returns the new integer value.
|
||||
* @example
|
||||
*
|
||||
* _.parseInt('08');
|
||||
* // => 8
|
||||
*/
|
||||
var parseInt = nativeParseInt('08') == 8 ? nativeParseInt : function(value, radix) {
|
||||
// Firefox and Opera have not changed to the ES5 specified implementation of `parseInt`
|
||||
return nativeParseInt(isString(value) ? value.replace(/^0+(?=.$)/, '') : value, radix || 0);
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a shallow clone of `object` composed of the specified properties.
|
||||
* Property names may be specified as individual arguments or as arrays of property
|
||||
@@ -5056,6 +5078,7 @@
|
||||
lodash.lastIndexOf = lastIndexOf;
|
||||
lodash.mixin = mixin;
|
||||
lodash.noConflict = noConflict;
|
||||
lodash.parseInt = parseInt;
|
||||
lodash.random = random;
|
||||
lodash.reduce = reduce;
|
||||
lodash.reduceRight = reduceRight;
|
||||
|
||||
Reference in New Issue
Block a user