SIGN IN SIGN UP

A modern JavaScript utility library delivering modularity, performance, & extras.

0 0 11 JavaScript
2016-01-28 01:16:24 -08:00
define(['./_root', './toString'], function(root, toString) {
2015-12-16 17:53:20 -08:00
Update lodash-amd to v4.17.21 + edadd45 (#6064) * Fix prototype pollution in _.set and related functions Prevents setting dangerous properties (__proto__, constructor, prototype) that could lead to prototype pollution vulnerabilities. * Fix command injection vulnerability in _.template - Add validation for the variable option to prevent injection attacks - Improve sourceURL whitespace normalization to prevent code injection * Fix cyclic value comparison in _.isEqual Properly checks both directions when comparing cyclic values to ensure correct equality comparisons for circular references. * Improve _.sortBy and _.orderBy performance and array handling - Add early return for empty arrays in sorted index operations - Improve array iteratee handling to support nested property paths - Add missing keysIn import in baseClone * Refactor _.trim, _.trimEnd, and _.trimStart implementations Extract shared trim logic into reusable utilities (_baseTrim, _trimmedEndIndex) for better code organization and consistency. Update related functions (toNumber, parseInt) to use new utilities. Improve comment accuracy. * Add documentation for predicate composition with _.overEvery and _.overSome Enhance documentation to show how _.matches and _.matchesProperty can be combined using _.overEvery and _.overSome for more powerful filtering. Add examples demonstrating shorthand predicate syntax. * Bump to v4.17.21 * Fix prototype pollution in _.unset and _.omit Prevent prototype pollution on baseUnset function by: - Blocking "__proto__" if not an own property - Blocking "constructor.prototype" chains (except when starting at primitive root) - Skipping non-string keys See: https://github.com/lodash/lodash/security/advisories/GHSA-xxjr-mmjv-4gpg * Update JSDoc documentation to align with main branch - Fix sortBy example ages (40 -> 30) for correct sort order demonstration - Fix _setCacheHas return type (number -> boolean)
2025-12-10 17:03:07 -05:00
/** Used to match leading whitespace. */
2016-09-25 13:37:46 -07:00
var reTrimStart = /^\s+/;
2015-12-16 17:53:20 -08:00
/* Built-in method references for those with the same name as other `lodash` methods. */
2015-01-08 00:37:01 -08:00
var nativeParseInt = root.parseInt;
/**
* Converts `string` to an integer of the specified radix. If `radix` is
2016-03-26 00:00:01 -07:00
* `undefined` or `0`, a `radix` of `10` is used unless `value` is a
* hexadecimal, in which case a `radix` of `16` is used.
2015-01-08 00:37:01 -08:00
*
2016-03-26 00:00:01 -07:00
* **Note:** This method aligns with the
* [ES5 implementation](https://es5.github.io/#x15.1.2.2) of `parseInt`.
2015-01-08 00:37:01 -08:00
*
* @static
* @memberOf _
2016-03-26 00:00:01 -07:00
* @since 1.1.0
2015-01-08 00:37:01 -08:00
* @category String
* @param {string} string The string to convert.
2016-02-15 20:20:54 -08:00
* @param {number} [radix=10] The radix to interpret `value` by.
2016-03-26 00:00:01 -07:00
* @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`.
2015-01-08 00:37:01 -08:00
* @returns {number} Returns the converted integer.
* @example
*
* _.parseInt('08');
* // => 8
*
* _.map(['6', '08', '10'], _.parseInt);
* // => [6, 8, 10]
*/
function parseInt(string, radix, guard) {
2015-12-16 17:53:20 -08:00
if (guard || radix == null) {
2015-01-08 00:37:01 -08:00
radix = 0;
2015-12-16 17:52:15 -08:00
} else if (radix) {
radix = +radix;
2015-01-08 00:37:01 -08:00
}
2016-09-25 13:37:46 -07:00
return nativeParseInt(toString(string).replace(reTrimStart, ''), radix || 0);
2015-01-08 00:37:01 -08:00
}
return parseInt;
});