vendor/assets/javascripts/lodash.core.js in lodash-rails-4.16.4 vs vendor/assets/javascripts/lodash.core.js in lodash-rails-4.16.6

- old
+ new

@@ -1,21 +1,21 @@ /** * @license * lodash (Custom Build) <https://lodash.com/> * Build: `lodash core -o ./dist/lodash.core.js` - * Copyright jQuery Foundation and other contributors <https://jquery.org/> + * Copyright JS Foundation and other contributors <https://js.foundation/> * Released under MIT license <https://lodash.com/license> * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */ ;(function() { /** Used as a safe reference for `undefined` in pre-ES5 environments. */ var undefined; /** Used as the semantic version number. */ - var VERSION = '4.16.4'; + var VERSION = '4.16.6'; /** Error message constants. */ var FUNC_ERROR_TEXT = 'Expected a function'; /** Used to compose bitmasks for function metadata. */ @@ -31,10 +31,11 @@ MAX_SAFE_INTEGER = 9007199254740991; /** `Object#toString` result references. */ var argsTag = '[object Arguments]', arrayTag = '[object Array]', + asyncTag = '[object AsyncFunction]', boolTag = '[object Boolean]', dateTag = '[object Date]', errorTag = '[object Error]', funcTag = '[object Function]', genTag = '[object GeneratorFunction]', @@ -212,11 +213,11 @@ /** * Used to resolve the * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ - var objectToString = objectProto.toString; + var nativeObjectToString = objectProto.toString; /** Used to restore the original `_` reference in `_.noConflict`. */ var oldDash = root._; /** Built-in value references. */ @@ -609,10 +610,21 @@ return isFunction(object[key]); }); } /** + * The base implementation of `getTag` without fallbacks for buggy environments. + * + * @private + * @param {*} value The value to query. + * @returns {string} Returns the `toStringTag`. + */ + function baseGetTag(value) { + return objectToString(value); + } + + /** * The base implementation of `_.gt` which doesn't coerce arguments. * * @private * @param {*} value The value to compare. * @param {*} other The other value to compare. @@ -638,11 +650,11 @@ * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a date object, else `false`. */ function baseIsDate(value) { - return isObjectLike(value) && objectToString.call(value) == dateTag; + return isObjectLike(value) && baseGetTag(value) == dateTag; } /** * The base implementation of `_.isEqual` which supports partial comparisons * and tracks traversed objects. @@ -688,15 +700,15 @@ othIsArr = isArray(other), objTag = arrayTag, othTag = arrayTag; if (!objIsArr) { - objTag = objectToString.call(object); + objTag = baseGetTag(object); objTag = objTag == argsTag ? objectTag : objTag; } if (!othIsArr) { - othTag = objectToString.call(other); + othTag = baseGetTag(other); othTag = othTag == argsTag ? objectTag : othTag; } var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, isSameTag = objTag == othTag; @@ -747,11 +759,11 @@ * @private * @param {*} value The value to check. * @returns {boolean} Returns `true` if `value` is a regexp, else `false`. */ function baseIsRegExp(value) { - return isObject(value) && objectToString.call(value) == regexpTag; + return isObjectLike(value) && baseGetTag(value) == regexpTag; } /** * The base implementation of `_.iteratee`. * @@ -1380,10 +1392,21 @@ } return result; } /** + * Converts `value` to a string using `Object.prototype.toString`. + * + * @private + * @param {*} value The value to convert. + * @returns {string} Returns the converted string. + */ + function objectToString(value) { + return nativeObjectToString.call(value); + } + + /** * A specialized version of `baseRest` which transforms the rest array. * * @private * @param {Function} func The function to apply a rest parameter to. * @param {number} [start=func.length-1] The start position of the rest parameter. @@ -1495,12 +1518,11 @@ * @static * @memberOf _ * @since 1.1.0 * @category Array * @param {Array} array The array to inspect. - * @param {Function} [predicate=_.identity] - * The function invoked per iteration. + * @param {Function} [predicate=_.identity] The function invoked per iteration. * @param {number} [fromIndex=0] The index to search from. * @returns {number} Returns the index of the found element, else `-1`. * @example * * var users = [ @@ -1523,11 +1545,11 @@ * // The `_.property` iteratee shorthand. * _.findIndex(users, 'active'); * // => 2 */ function findIndex(array, predicate, fromIndex) { - var length = array ? array.length : 0; + var length = array == null ? 0 : array.length; if (!length) { return -1; } var index = fromIndex == null ? 0 : toInteger(fromIndex); if (index < 0) { @@ -1549,11 +1571,11 @@ * * _.flatten([1, [2, [3, [4]], 5]]); * // => [1, 2, [3, [4]], 5] */ function flatten(array) { - var length = array ? array.length : 0; + var length = array == null ? 0 : array.length; return length ? baseFlatten(array, 1) : []; } /** * Recursively flattens `array`. @@ -1568,11 +1590,11 @@ * * _.flattenDeep([1, [2, [3, [4]], 5]]); * // => [1, 2, 3, 4, 5] */ function flattenDeep(array) { - var length = array ? array.length : 0; + var length = array == null ? 0 : array.length; return length ? baseFlatten(array, INFINITY) : []; } /** * Gets the first element of `array`. @@ -1618,11 +1640,11 @@ * // Search from the `fromIndex`. * _.indexOf([1, 2, 1, 2], 2, 2); * // => 3 */ function indexOf(array, value, fromIndex) { - var length = array ? array.length : 0; + var length = array == null ? 0 : array.length; if (typeof fromIndex == 'number') { fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex; } else { fromIndex = 0; } @@ -1651,11 +1673,11 @@ * * _.last([1, 2, 3]); * // => 3 */ function last(array) { - var length = array ? array.length : 0; + var length = array == null ? 0 : array.length; return length ? array[length - 1] : undefined; } /** * Creates a slice of `array` from `start` up to, but not including, `end`. @@ -1672,11 +1694,11 @@ * @param {number} [start=0] The start position. * @param {number} [end=array.length] The end position. * @returns {Array} Returns the slice of `array`. */ function slice(array, start, end) { - var length = array ? array.length : 0; + var length = array == null ? 0 : array.length; start = start == null ? 0 : +start; end = end === undefined ? length : +end; return length ? baseSlice(array, start, end) : []; } @@ -1836,12 +1858,11 @@ * @static * @memberOf _ * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [predicate=_.identity] - * The function invoked per iteration. + * @param {Function} [predicate=_.identity] The function invoked per iteration. * @param- {Object} [guard] Enables use as an iteratee for methods like `_.map`. * @returns {boolean} Returns `true` if all elements pass the predicate check, * else `false`. * @example * @@ -1880,12 +1901,11 @@ * @static * @memberOf _ * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function} [predicate=_.identity] - * The function invoked per iteration. + * @param {Function} [predicate=_.identity] The function invoked per iteration. * @returns {Array} Returns the new filtered array. * @see _.reject * @example * * var users = [ @@ -1920,12 +1940,11 @@ * @static * @memberOf _ * @since 0.1.0 * @category Collection * @param {Array|Object} collection The collection to inspect. - * @param {Function} [predicate=_.identity] - * The function invoked per iteration. + * @param {Function} [predicate=_.identity] The function invoked per iteration. * @param {number} [fromIndex=0] The index to search from. * @returns {*} Returns the matched element, else `undefined`. * @example * * var users = [ @@ -2519,11 +2538,11 @@ * _.isBoolean(null); * // => false */ function isBoolean(value) { return value === true || value === false || - (isObjectLike(value) && objectToString.call(value) == boolTag); + (isObjectLike(value) && baseGetTag(value) == boolTag); } /** * Checks if `value` is classified as a `Date` object. * @@ -2663,14 +2682,17 @@ * * _.isFunction(/abc/); * // => false */ function isFunction(value) { + if (!isObject(value)) { + return false; + } // The use of `Object#toString` avoids issues with the `typeof` operator - // in Safari 9 which returns 'object' for typed array and other constructors. - var tag = isObject(value) ? objectToString.call(value) : ''; - return tag == funcTag || tag == genTag || tag == proxyTag; + // in Safari 9 which returns 'object' for typed arrays and other constructors. + var tag = baseGetTag(value); + return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; } /** * Checks if `value` is a valid array-like length. * @@ -2842,11 +2864,11 @@ * _.isNumber('3'); * // => false */ function isNumber(value) { return typeof value == 'number' || - (isObjectLike(value) && objectToString.call(value) == numberTag); + (isObjectLike(value) && baseGetTag(value) == numberTag); } /** * Checks if `value` is classified as a `RegExp` object. * @@ -2883,11 +2905,11 @@ * _.isString(1); * // => false */ function isString(value) { return typeof value == 'string' || - (!isArray(value) && isObjectLike(value) && objectToString.call(value) == stringTag); + (!isArray(value) && isObjectLike(value) && baseGetTag(value) == stringTag); } /** * Checks if `value` is `undefined`. * @@ -3160,11 +3182,11 @@ * circle instanceof Shape; * // => true */ function create(prototype, properties) { var result = baseCreate(prototype); - return properties ? assign(result, properties) : result; + return properties == null ? result : assign(result, properties); } /** * Assigns own and inherited enumerable string keyed properties of source * objects to the destination object for all destination properties that @@ -3360,10 +3382,10 @@ * * _.values('hi'); * // => ['h', 'i'] */ function values(object) { - return object ? baseValues(object, keys(object)) : []; + return object == null ? [] : baseValues(object, keys(object)); } /*------------------------------------------------------------------------*/ /**