1 var root = require('./_root'),
2 toString = require('./toString');
4 /** Used to match leading and trailing whitespace. */
5 var reTrimStart = /^\s+/;
7 /* Built-in method references for those with the same name as other `lodash` methods. */
8 var nativeParseInt = root.parseInt;
11 * Converts `string` to an integer of the specified radix. If `radix` is
12 * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
13 * hexadecimal, in which case a `radix` of `16` is used.
15 * **Note:** This method aligns with the
16 * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
22 * @param {string} string The string to convert.
23 * @param {number} [radix=10] The radix to interpret `value` by.
24 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
25 * @returns {number} Returns the converted integer.
31 * _.map(['6', '08', '10'], _.parseInt);
34 function parseInt(string, radix, guard) {
35 if (guard || radix == null) {
40 return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
43 module.exports = parseInt;