CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
parseInt.js44 linesDownload Raw Back to lodash-es
1import root from './_root.js';2import toString from './toString.js';3 4/** Used to match leading whitespace. */5var reTrimStart = /^\s+/;6 7/* Built-in method references for those with the same name as other `lodash` methods. */8var nativeParseInt = root.parseInt;9 10/**11 * Converts `string` to an integer of the specified radix. If `radix` is12 * `undefined` or `0`, a `radix` of `10` is used unless `value` is a13 * hexadecimal, in which case a `radix` of `16` is used.14 *15 * **Note:** This method aligns with the16 * [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.17 *18 * @static19 * @memberOf _20 * @since 1.1.021 * @category String22 * @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.26 * @example27 *28 * _.parseInt('08');29 * // => 830 *31 * _.map(['6', '08', '10'], _.parseInt);32 * // => [6, 8, 10]33 */34function parseInt(string, radix, guard) {35  if (guard || radix == null) {36    radix = 0;37  } else if (radix) {38    radix = +radix;39  }40  return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);41}42 43export default parseInt;44 
basant307/AI_Governance_Project · CoolFace