Updated to Drupal 8.6.4, which is PHP 7.3 friendly. Also updated HTMLaw library....
[yaffs-website] / node_modules / grunt-legacy-util / node_modules / lodash / parseInt.js
1 var root = require('./_root'),
2     toString = require('./toString');
3
4 /** Used to match leading and trailing whitespace. */
5 var reTrim = /^\s+|\s+$/g;
6
7 /** Used to detect hexadecimal string values. */
8 var reHasHexPrefix = /^0x/i;
9
10 /* Built-in method references for those with the same name as other `lodash` methods. */
11 var nativeParseInt = root.parseInt;
12
13 /**
14  * Converts `string` to an integer of the specified radix. If `radix` is
15  * `undefined` or `0`, a `radix` of `10` is used unless `value` is a hexadecimal,
16  * in which case a `radix` of `16` is used.
17  *
18  * **Note:** This method aligns with the [ES5 implementation](https://es5.github.io/#x15.1.2.2)
19  * of `parseInt`.
20  *
21  * @static
22  * @memberOf _
23  * @category String
24  * @param {string} string The string to convert.
25  * @param {number} [radix] The radix to interpret `value` by.
26  * @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`.
27  * @returns {number} Returns the converted integer.
28  * @example
29  *
30  * _.parseInt('08');
31  * // => 8
32  *
33  * _.map(['6', '08', '10'], _.parseInt);
34  * // => [6, 8, 10]
35  */
36 function parseInt(string, radix, guard) {
37   // Chrome fails to trim leading <BOM> whitespace characters.
38   // See https://code.google.com/p/v8/issues/detail?id=3109 for more details.
39   if (guard || radix == null) {
40     radix = 0;
41   } else if (radix) {
42     radix = +radix;
43   }
44   string = toString(string).replace(reTrim, '');
45   return nativeParseInt(string, radix || (reHasHexPrefix.test(string) ? 16 : 10));
46 }
47
48 module.exports = parseInt;