Sha256: 947eae4b5773c2df1900ade13faea9f1e0ca1a034377c60535599b31bdd28e82

Contents?: true

Size: 1.23 KB

Versions: 101

Compression:

Stored size: 1.23 KB

Contents

var root = require('./_root'),
    toString = require('./toString');

/** Used to match leading whitespace. */
var reTrimStart = /^\s+/;

/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeParseInt = root.parseInt;

/**
 * Converts `string` to an integer of the specified radix. If `radix` is
 * `undefined` or `0`, a `radix` of `10` is used unless `value` is a
 * hexadecimal, in which case a `radix` of `16` is used.
 *
 * **Note:** This method aligns with the
 * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
 *
 * @static
 * @memberOf _
 * @since 1.1.0
 * @category String
 * @param {string} string The string to convert.
 * @param {number} [radix=10] The radix to interpret `value` by.
 * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
 * @returns {number} Returns the converted integer.
 * @example
 *
 * _.parseInt('08');
 * // => 8
 *
 * _.map(['6', '08', '10'], _.parseInt);
 * // => [6, 8, 10]
 */
function parseInt(string, radix, guard) {
  if (guard || radix == null) {
    radix = 0;
  } else if (radix) {
    radix = +radix;
  }
  return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
}

module.exports = parseInt;

Version data entries

101 entries across 100 versions & 8 rubygems

Version Path
appmap-0.67.0 ./node_modules/lodash/parseInt.js
appmap-0.66.2 ./node_modules/lodash/parseInt.js
trusty-cms-5.0.1 node_modules/lodash/parseInt.js
trusty-cms-4.3.5 node_modules/lodash/parseInt.js
trusty-cms-5.0.0 node_modules/lodash/parseInt.js
appmap-0.66.1 ./node_modules/lodash/parseInt.js
appmap-0.66.0 ./node_modules/lodash/parseInt.js
appmap-0.65.1 ./node_modules/lodash/parseInt.js
appmap-0.65.0 ./node_modules/lodash/parseInt.js
trusty-cms-4.3.4 node_modules/lodash/parseInt.js
appmap-0.64.0 ./node_modules/lodash/parseInt.js
appmap-0.63.0 ./node_modules/lodash/parseInt.js
jekyll-esm-0.0.3 node_modules/lodash/parseInt.js
trusty-cms-4.3.3 node_modules/lodash/parseInt.js
trusty-cms-4.3.2 node_modules/lodash/parseInt.js
trusty-cms-4.3.1 node_modules/lodash/parseInt.js
trusty-cms-4.2.3 node_modules/lodash/parseInt.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/lodash/parseInt.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/lodash/parseInt.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/lodash/parseInt.js