X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=node_modules%2Fgrunt-legacy-log-utils%2Fnode_modules%2Flodash%2FparseInt.js;fp=node_modules%2Fgrunt-legacy-log-utils%2Fnode_modules%2Flodash%2FparseInt.js;h=ae608ce59f949d85f8924119ed4d613cdd2af065;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/node_modules/grunt-legacy-log-utils/node_modules/lodash/parseInt.js b/node_modules/grunt-legacy-log-utils/node_modules/lodash/parseInt.js new file mode 100644 index 000000000..ae608ce59 --- /dev/null +++ b/node_modules/grunt-legacy-log-utils/node_modules/lodash/parseInt.js @@ -0,0 +1,48 @@ +var root = require('./_root'), + toString = require('./toString'); + +/** Used to match leading and trailing whitespace. */ +var reTrim = /^\s+|\s+$/g; + +/** Used to detect hexadecimal string values. */ +var reHasHexPrefix = /^0x/i; + +/* 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 _ + * @category String + * @param {string} string The string to convert. + * @param {number} [radix] The radix to interpret `value` by. + * @param- {Object} [guard] Enables use as an iteratee for functions 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) { + // Chrome fails to trim leading whitespace characters. + // See https://code.google.com/p/v8/issues/detail?id=3109 for more details. + if (guard || radix == null) { + radix = 0; + } else if (radix) { + radix = +radix; + } + string = toString(string).replace(reTrim, ''); + return nativeParseInt(string, radix || (reHasHexPrefix.test(string) ? 16 : 10)); +} + +module.exports = parseInt;