diff --git a/README.md b/README.md index 1f769e3a1..c46df68d2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# lodash-amd v4.14.1 +# lodash-amd v4.14.2 The [Lodash](https://lodash.com/) library exported as [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules. @@ -27,4 +27,4 @@ require({ }); ``` -See the [package source](https://github.com/lodash/lodash/tree/4.14.1-amd) for more details. +See the [package source](https://github.com/lodash/lodash/tree/4.14.2-amd) for more details. diff --git a/_Reflect.js b/_Reflect.js deleted file mode 100644 index b0fcc5d42..000000000 --- a/_Reflect.js +++ /dev/null @@ -1,7 +0,0 @@ -define(['./_root'], function(root) { - - /** Built-in value references. */ - var Reflect = root.Reflect; - - return Reflect; -}); diff --git a/_arrayLikeKeys.js b/_arrayLikeKeys.js new file mode 100644 index 000000000..4f33c1cd3 --- /dev/null +++ b/_arrayLikeKeys.js @@ -0,0 +1,35 @@ +define(['./_baseTimes', './isArguments', './isArray', './_isIndex', './isString'], function(baseTimes, isArguments, isArray, isIndex, isString) { + + /** Used for built-in method references. */ + var objectProto = Object.prototype; + + /** Used to check objects for own properties. */ + var hasOwnProperty = objectProto.hasOwnProperty; + + /** + * Creates an array of the enumerable property names of the array-like `value`. + * + * @private + * @param {*} value The value to query. + * @param {boolean} inherited Specify returning inherited property names. + * @returns {Array} Returns the array of property names. + */ + function arrayLikeKeys(value, inherited) { + var result = (isArray(value) || isString(value) || isArguments(value)) + ? baseTimes(value.length, String) + : []; + + var length = result.length, + skipIndexes = !!length; + + for (var key in value) { + if ((inherited || hasOwnProperty.call(value, key)) && + !(skipIndexes && (key == 'length' || isIndex(key, length)))) { + result.push(key); + } + } + return result; + } + + return arrayLikeKeys; +}); diff --git a/_assignValue.js b/_assignValue.js index c93e69b4b..c6a7cba31 100644 --- a/_assignValue.js +++ b/_assignValue.js @@ -11,7 +11,7 @@ define(['./eq'], function(eq) { /** * Assigns `value` to `key` of `object` if the existing value is not equivalent - * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons. * * @private diff --git a/_baseConformsTo.js b/_baseConformsTo.js index 46bd8a088..6a8dcf2ce 100644 --- a/_baseConformsTo.js +++ b/_baseConformsTo.js @@ -16,14 +16,13 @@ define([], function() { if (object == null) { return !length; } - var index = length; - while (index--) { - var key = props[index], + object = Object(object); + while (length--) { + var key = props[length], predicate = source[key], value = object[key]; - if ((value === undefined && - !(key in Object(object))) || !predicate(value)) { + if ((value === undefined && !(key in object)) || !predicate(value)) { return false; } } diff --git a/_baseDelay.js b/_baseDelay.js index a4589e785..9344e48ec 100644 --- a/_baseDelay.js +++ b/_baseDelay.js @@ -14,7 +14,7 @@ define([], function() { * @param {Function} func The function to delay. * @param {number} wait The number of milliseconds to delay invocation. * @param {Array} args The arguments to provide to `func`. - * @returns {number} Returns the timer id. + * @returns {number|Object} Returns the timer id or timeout object. */ function baseDelay(func, wait, args) { if (typeof func != 'function') { diff --git a/_baseGetTag.js b/_baseGetTag.js index c1d0e3116..62a8a2477 100644 --- a/_baseGetTag.js +++ b/_baseGetTag.js @@ -5,7 +5,7 @@ define([], function() { /** * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var objectToString = objectProto.toString; diff --git a/_baseHas.js b/_baseHas.js index 51eb1eadb..8c069c6ff 100644 --- a/_baseHas.js +++ b/_baseHas.js @@ -1,4 +1,4 @@ -define(['./_getPrototype'], function(getPrototype) { +define([], function() { /** Used for built-in method references. */ var objectProto = Object.prototype; @@ -15,12 +15,7 @@ define(['./_getPrototype'], function(getPrototype) { * @returns {boolean} Returns `true` if `key` exists, else `false`. */ function baseHas(object, key) { - // Avoid a bug in IE 10-11 where objects with a [[Prototype]] of `null`, - // that are composed entirely of index properties, return `false` for - // `hasOwnProperty` checks of them. - return object != null && - (hasOwnProperty.call(object, key) || - (typeof object == 'object' && key in object && getPrototype(object) === null)); + return object != null && hasOwnProperty.call(object, key); } return baseHas; diff --git a/_baseIsArrayBuffer.js b/_baseIsArrayBuffer.js index 837dbfd43..6e6e5caeb 100644 --- a/_baseIsArrayBuffer.js +++ b/_baseIsArrayBuffer.js @@ -7,7 +7,7 @@ define(['./isObjectLike'], function(isObjectLike) { /** * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var objectToString = objectProto.toString; diff --git a/_baseIsDate.js b/_baseIsDate.js index ecffb6246..d7029b98f 100644 --- a/_baseIsDate.js +++ b/_baseIsDate.js @@ -8,7 +8,7 @@ define(['./isObjectLike'], function(isObjectLike) { /** * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var objectToString = objectProto.toString; diff --git a/_baseIsNative.js b/_baseIsNative.js index 3c8346644..3c1867cdd 100644 --- a/_baseIsNative.js +++ b/_baseIsNative.js @@ -2,7 +2,7 @@ define(['./isFunction', './_isHostObject', './_isMasked', './isObject', './_toSo /** * Used to match `RegExp` - * [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns). + * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). */ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; diff --git a/_baseIsRegExp.js b/_baseIsRegExp.js index 1cbd88604..3ccd3d813 100644 --- a/_baseIsRegExp.js +++ b/_baseIsRegExp.js @@ -8,7 +8,7 @@ define(['./isObject'], function(isObject) { /** * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var objectToString = objectProto.toString; diff --git a/_baseIsTypedArray.js b/_baseIsTypedArray.js index 0bacaf06f..0413fbef3 100644 --- a/_baseIsTypedArray.js +++ b/_baseIsTypedArray.js @@ -48,7 +48,7 @@ define(['./isLength', './isObjectLike'], function(isLength, isObjectLike) { /** * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var objectToString = objectProto.toString; diff --git a/_baseKeys.js b/_baseKeys.js index ee94f3748..88fdb4e3b 100644 --- a/_baseKeys.js +++ b/_baseKeys.js @@ -1,17 +1,30 @@ -define(['./_overArg'], function(overArg) { +define(['./_isPrototype', './_nativeKeys'], function(isPrototype, nativeKeys) { - /* Built-in method references for those with the same name as other `lodash` methods. */ - var nativeKeys = Object.keys; + /** Used for built-in method references. */ + var objectProto = Object.prototype; + + /** Used to check objects for own properties. */ + var hasOwnProperty = objectProto.hasOwnProperty; /** - * The base implementation of `_.keys` which doesn't skip the constructor - * property of prototypes or treat sparse arrays as dense. + * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of property names. */ - var baseKeys = overArg(nativeKeys, Object); + function baseKeys(object) { + if (!isPrototype(object)) { + return nativeKeys(object); + } + var result = []; + for (var key in Object(object)) { + if (hasOwnProperty.call(object, key) && key != 'constructor') { + result.push(key); + } + } + return result; + } return baseKeys; }); diff --git a/_baseKeysIn.js b/_baseKeysIn.js index ed8a694a8..e4b845c4e 100644 --- a/_baseKeysIn.js +++ b/_baseKeysIn.js @@ -1,39 +1,32 @@ -define(['./_Reflect', './_iteratorToArray'], function(Reflect, iteratorToArray) { - - /** Used as a safe reference for `undefined` in pre-ES5 environments. */ - var undefined; +define(['./isObject', './_isPrototype', './_nativeKeysIn'], function(isObject, isPrototype, nativeKeysIn) { /** Used for built-in method references. */ var objectProto = Object.prototype; - /** Built-in value references. */ - var enumerate = Reflect ? Reflect.enumerate : undefined, - propertyIsEnumerable = objectProto.propertyIsEnumerable; + /** Used to check objects for own properties. */ + var hasOwnProperty = objectProto.hasOwnProperty; /** - * The base implementation of `_.keysIn` which doesn't skip the constructor - * property of prototypes or treat sparse arrays as dense. + * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of property names. */ function baseKeysIn(object) { - object = object == null ? object : Object(object); + if (!isObject(object)) { + return nativeKeysIn(object); + } + var isProto = isPrototype(object), + result = []; - var result = []; for (var key in object) { - result.push(key); + if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { + result.push(key); + } } return result; } - // Fallback for IE < 9 with es6-shim. - if (enumerate && !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf')) { - baseKeysIn = function(object) { - return iteratorToArray(enumerate(object)); - }; - } - return baseKeysIn; }); diff --git a/_baseMerge.js b/_baseMerge.js index 201dae764..e7b16a4c1 100644 --- a/_baseMerge.js +++ b/_baseMerge.js @@ -1,4 +1,4 @@ -define(['./_Stack', './_arrayEach', './_assignMergeValue', './_baseMergeDeep', './isArray', './isObject', './isTypedArray', './keysIn'], function(Stack, arrayEach, assignMergeValue, baseMergeDeep, isArray, isObject, isTypedArray, keysIn) { +define(['./_Stack', './_arrayEach', './_assignMergeValue', './_baseKeysIn', './_baseMergeDeep', './isArray', './isObject', './isTypedArray'], function(Stack, arrayEach, assignMergeValue, baseKeysIn, baseMergeDeep, isArray, isObject, isTypedArray) { /** Used as a safe reference for `undefined` in pre-ES5 environments. */ var undefined; @@ -19,7 +19,7 @@ define(['./_Stack', './_arrayEach', './_assignMergeValue', './_baseMergeDeep', ' return; } if (!(isArray(source) || isTypedArray(source))) { - var props = keysIn(source); + var props = baseKeysIn(source); } arrayEach(props || source, function(srcValue, key) { if (props) { diff --git a/_baseSet.js b/_baseSet.js index 112cd3ab2..b6e9554c9 100644 --- a/_baseSet.js +++ b/_baseSet.js @@ -14,6 +14,9 @@ define(['./_assignValue', './_castPath', './_isIndex', './_isKey', './isObject', * @returns {Object} Returns `object`. */ function baseSet(object, path, value, customizer) { + if (!isObject(object)) { + return object; + } path = isKey(path, object) ? [path] : castPath(path); var index = -1, @@ -22,20 +25,19 @@ define(['./_assignValue', './_castPath', './_isIndex', './_isKey', './isObject', nested = object; while (nested != null && ++index < length) { - var key = toKey(path[index]); - if (isObject(nested)) { - var newValue = value; - if (index != lastIndex) { - var objValue = nested[key]; - newValue = customizer ? customizer(objValue, key, nested) : undefined; - if (newValue === undefined) { - newValue = objValue == null - ? (isIndex(path[index + 1]) ? [] : {}) - : objValue; - } + var key = toKey(path[index]), + newValue = value; + + if (index != lastIndex) { + var objValue = nested[key]; + newValue = customizer ? customizer(objValue, key, nested) : undefined; + if (newValue === undefined) { + newValue = isObject(objValue) + ? objValue + : (isIndex(path[index + 1]) ? [] : {}); } - assignValue(nested, key, newValue); } + assignValue(nested, key, newValue); nested = nested[key]; } return object; diff --git a/_baseUnset.js b/_baseUnset.js index 8db380046..8899ef343 100644 --- a/_baseUnset.js +++ b/_baseUnset.js @@ -1,4 +1,10 @@ -define(['./_baseHas', './_castPath', './_isKey', './last', './_parent', './_toKey'], function(baseHas, castPath, isKey, last, parent, toKey) { +define(['./_castPath', './_isKey', './last', './_parent', './_toKey'], function(castPath, isKey, last, parent, toKey) { + + /** Used for built-in method references. */ + var objectProto = Object.prototype; + + /** Used to check objects for own properties. */ + var hasOwnProperty = objectProto.hasOwnProperty; /** * The base implementation of `_.unset`. @@ -13,7 +19,7 @@ define(['./_baseHas', './_castPath', './_isKey', './last', './_parent', './_toKe object = parent(object, path); var key = toKey(last(path)); - return !(object != null && baseHas(object, key)) || delete object[key]; + return !(object != null && hasOwnProperty.call(object, key)) || delete object[key]; } return baseUnset; diff --git a/_createCtor.js b/_createCtor.js index ef5d00f24..96e472e6b 100644 --- a/_createCtor.js +++ b/_createCtor.js @@ -11,7 +11,7 @@ define(['./_baseCreate', './isObject'], function(baseCreate, isObject) { function createCtor(Ctor) { return function() { // Use a `switch` statement to work with class constructors. See - // http://ecma-international.org/ecma-262/6.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist + // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist // for more details. var args = arguments; switch (args.length) { diff --git a/_equalByTag.js b/_equalByTag.js index 196993702..51df7a919 100644 --- a/_equalByTag.js +++ b/_equalByTag.js @@ -73,7 +73,7 @@ define(['./_Symbol', './_Uint8Array', './eq', './_equalArrays', './_mapToArray', case regexpTag: case stringTag: // Coerce regexes to strings and treat strings, primitives and objects, - // as equal. See http://www.ecma-international.org/ecma-262/6.0/#sec-regexp.prototype.tostring + // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring // for more details. return object == (other + ''); diff --git a/_equalObjects.js b/_equalObjects.js index 94c4a9a60..df4cc37b5 100644 --- a/_equalObjects.js +++ b/_equalObjects.js @@ -1,4 +1,4 @@ -define(['./_baseHas', './keys'], function(baseHas, keys) { +define(['./keys'], function(keys) { /** Used as a safe reference for `undefined` in pre-ES5 environments. */ var undefined; @@ -6,6 +6,12 @@ define(['./_baseHas', './keys'], function(baseHas, keys) { /** Used to compose bitmasks for comparison styles. */ var PARTIAL_COMPARE_FLAG = 2; + /** Used for built-in method references. */ + var objectProto = Object.prototype; + + /** Used to check objects for own properties. */ + var hasOwnProperty = objectProto.hasOwnProperty; + /** * A specialized version of `baseIsEqualDeep` for objects with support for * partial deep comparisons. @@ -33,7 +39,7 @@ define(['./_baseHas', './keys'], function(baseHas, keys) { var index = objLength; while (index--) { var key = objProps[index]; - if (!(isPartial ? key in other : baseHas(other, key))) { + if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { return false; } } diff --git a/_getLength.js b/_getLength.js deleted file mode 100644 index d59b46856..000000000 --- a/_getLength.js +++ /dev/null @@ -1,17 +0,0 @@ -define(['./_baseProperty'], function(baseProperty) { - - /** - * Gets the "length" property value of `object`. - * - * **Note:** This function is used to avoid a - * [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) that affects - * Safari on at least iOS 8.1-8.3 ARM64. - * - * @private - * @param {Object} object The object to query. - * @returns {*} Returns the "length" value. - */ - var getLength = baseProperty('length'); - - return getLength; -}); diff --git a/_getPrototype.js b/_getPrototype.js index 23b90a35f..a2e50e8c0 100644 --- a/_getPrototype.js +++ b/_getPrototype.js @@ -1,16 +1,7 @@ define(['./_overArg'], function(overArg) { - /* Built-in method references for those with the same name as other `lodash` methods. */ - var nativeGetPrototype = Object.getPrototypeOf; - - /** - * Gets the `[[Prototype]]` of `value`. - * - * @private - * @param {*} value The value to query. - * @returns {null|Object} Returns the `[[Prototype]]`. - */ - var getPrototype = overArg(nativeGetPrototype, Object); + /** Built-in value references. */ + var getPrototype = overArg(Object.getPrototypeOf, Object); return getPrototype; }); diff --git a/_getTag.js b/_getTag.js index fb364a10b..17cb0c6b4 100644 --- a/_getTag.js +++ b/_getTag.js @@ -17,7 +17,7 @@ define(['./_DataView', './_Map', './_Promise', './_Set', './_WeakMap', './_baseG /** * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var objectToString = objectProto.toString; diff --git a/_indexKeys.js b/_indexKeys.js deleted file mode 100644 index 06ad5b4c9..000000000 --- a/_indexKeys.js +++ /dev/null @@ -1,24 +0,0 @@ -define(['./_baseTimes', './isArguments', './isArray', './isLength', './isString'], function(baseTimes, isArguments, isArray, isLength, isString) { - - /** Used as a safe reference for `undefined` in pre-ES5 environments. */ - var undefined; - - /** - * Creates an array of index keys for `object` values of arrays, - * `arguments` objects, and strings, otherwise `null` is returned. - * - * @private - * @param {Object} object The object to query. - * @returns {Array|null} Returns index keys, else `null`. - */ - function indexKeys(object) { - var length = object ? object.length : undefined; - if (isLength(length) && - (isArray(object) || isString(object) || isArguments(object))) { - return baseTimes(length, String); - } - return null; - } - - return indexKeys; -}); diff --git a/_nativeKeys.js b/_nativeKeys.js new file mode 100644 index 000000000..492fd82c4 --- /dev/null +++ b/_nativeKeys.js @@ -0,0 +1,7 @@ +define(['./_overArg'], function(overArg) { + + /* Built-in method references for those with the same name as other `lodash` methods. */ + var nativeKeys = overArg(Object.keys, Object); + + return nativeKeys; +}); diff --git a/_nativeKeysIn.js b/_nativeKeysIn.js new file mode 100644 index 000000000..011992d9f --- /dev/null +++ b/_nativeKeysIn.js @@ -0,0 +1,23 @@ +define([], function() { + + /** + * This function is like + * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * except that it includes inherited enumerable properties. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ + function nativeKeysIn(object) { + var result = []; + if (object != null) { + for (var key in Object(object)) { + result.push(key); + } + } + return result; + } + + return nativeKeysIn; +}); diff --git a/_overArg.js b/_overArg.js index e39423dfb..4d72f4637 100644 --- a/_overArg.js +++ b/_overArg.js @@ -1,7 +1,7 @@ define([], function() { /** - * Creates a function that invokes `func` with its first argument transformed. + * Creates a unary function that invokes `func` with its argument transformed. * * @private * @param {Function} func The function to wrap. diff --git a/assignIn.js b/assignIn.js index a9533795e..29b084172 100644 --- a/assignIn.js +++ b/assignIn.js @@ -1,13 +1,4 @@ -define(['./_assignValue', './_copyObject', './_createAssigner', './isArrayLike', './_isPrototype', './keysIn'], function(assignValue, copyObject, createAssigner, isArrayLike, isPrototype, keysIn) { - - /** Used for built-in method references. */ - var objectProto = Object.prototype; - - /** Built-in value references. */ - var propertyIsEnumerable = objectProto.propertyIsEnumerable; - - /** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */ - var nonEnumShadows = !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf'); +define(['./_copyObject', './_createAssigner', './keysIn'], function(copyObject, createAssigner, keysIn) { /** * This method is like `_.assign` except that it iterates over own and @@ -41,13 +32,7 @@ define(['./_assignValue', './_copyObject', './_createAssigner', './isArrayLike', * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } */ var assignIn = createAssigner(function(object, source) { - if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) { - copyObject(source, keysIn(source), object); - return; - } - for (var key in source) { - assignValue(object, key, source[key]); - } + copyObject(source, keysIn(source), object); }); return assignIn; diff --git a/difference.js b/difference.js index 862d89549..c5cdf9614 100644 --- a/difference.js +++ b/difference.js @@ -2,7 +2,7 @@ define(['./_baseDifference', './_baseFlatten', './_baseRest', './isArrayLikeObje /** * Creates an array of `array` values not included in the other given arrays - * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons. The order of result values is determined by the * order they occur in the first array. * diff --git a/eq.js b/eq.js index 0c5a2d712..ad2605d7e 100644 --- a/eq.js +++ b/eq.js @@ -2,7 +2,7 @@ define([], function() { /** * Performs a - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * comparison between two values to determine if they are equivalent. * * @static diff --git a/escapeRegExp.js b/escapeRegExp.js index 03d653aed..fed17caa9 100644 --- a/escapeRegExp.js +++ b/escapeRegExp.js @@ -2,7 +2,7 @@ define(['./toString'], function(toString) { /** * Used to match `RegExp` - * [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns). + * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). */ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, reHasRegExpChar = RegExp(reRegExpChar.source); diff --git a/every.js b/every.js index 80b70a316..b9aeeee9d 100644 --- a/every.js +++ b/every.js @@ -8,6 +8,11 @@ define(['./_arrayEvery', './_baseEvery', './_baseIteratee', './isArray', './_isI * Iteration is stopped once `predicate` returns falsey. The predicate is * invoked with three arguments: (value, index|key, collection). * + * **Note:** This method returns `true` for + * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because + * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of + * elements of empty collections. + * * @static * @memberOf _ * @since 0.1.0 diff --git a/includes.js b/includes.js index e244655ba..19fbc218b 100644 --- a/includes.js +++ b/includes.js @@ -6,7 +6,7 @@ define(['./_baseIndexOf', './isArrayLike', './isString', './toInteger', './value /** * Checks if `value` is in `collection`. If `collection` is a string, it's * checked for a substring of `value`, otherwise - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * is used for equality comparisons. If `fromIndex` is negative, it's used as * the offset from the end of `collection`. * diff --git a/indexOf.js b/indexOf.js index 890f01a08..2ec35078f 100644 --- a/indexOf.js +++ b/indexOf.js @@ -5,7 +5,7 @@ define(['./_baseIndexOf', './toInteger'], function(baseIndexOf, toInteger) { /** * Gets the index at which the first occurrence of `value` is found in `array` - * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons. If `fromIndex` is negative, it's used as the * offset from the end of `array`. * diff --git a/initial.js b/initial.js index 0bfabc051..7f68d75c3 100644 --- a/initial.js +++ b/initial.js @@ -1,4 +1,4 @@ -define(['./dropRight'], function(dropRight) { +define(['./_baseSlice'], function(baseSlice) { /** * Gets all but the last element of `array`. @@ -15,7 +15,8 @@ define(['./dropRight'], function(dropRight) { * // => [1, 2] */ function initial(array) { - return dropRight(array, 1); + var length = array ? array.length : 0; + return length ? baseSlice(array, 0, -1) : []; } return initial; diff --git a/intersection.js b/intersection.js index 6b8a69fdf..ae21fefa8 100644 --- a/intersection.js +++ b/intersection.js @@ -2,7 +2,7 @@ define(['./_arrayMap', './_baseIntersection', './_baseRest', './_castArrayLikeOb /** * Creates an array of unique values that are included in all given arrays - * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons. The order of result values is determined by the * order they occur in the first array. * diff --git a/isArguments.js b/isArguments.js index d6b4150a3..dc2671cfd 100644 --- a/isArguments.js +++ b/isArguments.js @@ -11,7 +11,7 @@ define(['./isArrayLikeObject'], function(isArrayLikeObject) { /** * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var objectToString = objectProto.toString; diff --git a/isArrayLike.js b/isArrayLike.js index c8cd8761c..915c47e1f 100644 --- a/isArrayLike.js +++ b/isArrayLike.js @@ -1,4 +1,4 @@ -define(['./_getLength', './isFunction', './isLength'], function(getLength, isFunction, isLength) { +define(['./isFunction', './isLength'], function(isFunction, isLength) { /** * Checks if `value` is array-like. A value is considered array-like if it's @@ -26,7 +26,7 @@ define(['./_getLength', './isFunction', './isLength'], function(getLength, isFun * // => false */ function isArrayLike(value) { - return value != null && isLength(getLength(value)) && !isFunction(value); + return value != null && isLength(value.length) && !isFunction(value); } return isArrayLike; diff --git a/isBoolean.js b/isBoolean.js index 22d848b06..7d95eb023 100644 --- a/isBoolean.js +++ b/isBoolean.js @@ -8,7 +8,7 @@ define(['./isObjectLike'], function(isObjectLike) { /** * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var objectToString = objectProto.toString; diff --git a/isElement.js b/isElement.js index 5ed4aec74..a801d56ec 100644 --- a/isElement.js +++ b/isElement.js @@ -8,8 +8,7 @@ define(['./isObjectLike', './isPlainObject'], function(isObjectLike, isPlainObje * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a DOM element, - * else `false`. + * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. * @example * * _.isElement(document.body); diff --git a/isEmpty.js b/isEmpty.js index 99db7ed95..c83b7ee79 100644 --- a/isEmpty.js +++ b/isEmpty.js @@ -1,4 +1,4 @@ -define(['./_getTag', './isArguments', './isArray', './isArrayLike', './isBuffer', './isFunction', './isObjectLike', './isString', './keys'], function(getTag, isArguments, isArray, isArrayLike, isBuffer, isFunction, isObjectLike, isString, keys) { +define(['./_getTag', './isArguments', './isArray', './isArrayLike', './isBuffer', './isFunction', './isObjectLike', './_isPrototype', './isString', './_nativeKeys'], function(getTag, isArguments, isArray, isArrayLike, isBuffer, isFunction, isObjectLike, isPrototype, isString, nativeKeys) { /** `Object#toString` result references. */ var mapTag = '[object Map]', @@ -61,12 +61,14 @@ define(['./_getTag', './isArguments', './isArray', './isArrayLike', './isBuffer' return !value.size; } } + var isProto = isPrototype(value); for (var key in value) { - if (hasOwnProperty.call(value, key)) { + if (hasOwnProperty.call(value, key) && + !(isProto && key == 'constructor')) { return false; } } - return !(nonEnumShadows && keys(value).length); + return !(nonEnumShadows && nativeKeys(value).length); } return isEmpty; diff --git a/isEqual.js b/isEqual.js index c53bff31f..605e44613 100644 --- a/isEqual.js +++ b/isEqual.js @@ -16,8 +16,7 @@ define(['./_baseIsEqual'], function(baseIsEqual) { * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, - * else `false`. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. * @example * * var object = { 'a': 1 }; diff --git a/isEqualWith.js b/isEqualWith.js index c4c3a07de..c4e62066c 100644 --- a/isEqualWith.js +++ b/isEqualWith.js @@ -16,8 +16,7 @@ define(['./_baseIsEqual'], function(baseIsEqual) { * @param {*} value The value to compare. * @param {*} other The other value to compare. * @param {Function} [customizer] The function to customize comparisons. - * @returns {boolean} Returns `true` if the values are equivalent, - * else `false`. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. * @example * * function isGreeting(value) { diff --git a/isError.js b/isError.js index 914544755..4eb11cee3 100644 --- a/isError.js +++ b/isError.js @@ -8,7 +8,7 @@ define(['./isObjectLike'], function(isObjectLike) { /** * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var objectToString = objectProto.toString; @@ -22,8 +22,7 @@ define(['./isObjectLike'], function(isObjectLike) { * @since 3.0.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an error object, - * else `false`. + * @returns {boolean} Returns `true` if `value` is an error object, else `false`. * @example * * _.isError(new Error); diff --git a/isFinite.js b/isFinite.js index 9ae9d842b..11cbc317d 100644 --- a/isFinite.js +++ b/isFinite.js @@ -14,8 +14,7 @@ define(['./_root'], function(root) { * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a finite number, - * else `false`. + * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. * @example * * _.isFinite(3); diff --git a/isFunction.js b/isFunction.js index 4d3667fb5..e8044df2b 100644 --- a/isFunction.js +++ b/isFunction.js @@ -9,7 +9,7 @@ define(['./isObject'], function(isObject) { /** * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var objectToString = objectProto.toString; diff --git a/isLength.js b/isLength.js index 3cde9c1af..4a7f3746b 100644 --- a/isLength.js +++ b/isLength.js @@ -6,16 +6,15 @@ define([], function() { /** * Checks if `value` is a valid array-like length. * - * **Note:** This function is loosely based on - * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). + * **Note:** This method is loosely based on + * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, - * else `false`. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. * @example * * _.isLength(3); diff --git a/isMatch.js b/isMatch.js index 89e317ead..f71bcd082 100644 --- a/isMatch.js +++ b/isMatch.js @@ -4,8 +4,12 @@ define(['./_baseIsMatch', './_getMatchData'], function(baseIsMatch, getMatchData * Performs a partial deep comparison between `object` and `source` to * determine if `object` contains equivalent property values. * - * **Note:** This method supports comparing the same values as `_.isEqual` - * and is equivalent to `_.matches` when `source` is partially applied. + * **Note:** This method is equivalent to `_.matches` when `source` is + * partially applied. + * + * Partial comparisons will match empty array and empty object `source` + * values against any array or object value, respectively. See `_.isEqual` + * for a list of supported value comparisons. * * @static * @memberOf _ diff --git a/isNumber.js b/isNumber.js index f276a2438..777a8e227 100644 --- a/isNumber.js +++ b/isNumber.js @@ -8,7 +8,7 @@ define(['./isObjectLike'], function(isObjectLike) { /** * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var objectToString = objectProto.toString; diff --git a/isObject.js b/isObject.js index 1c760012c..5480483df 100644 --- a/isObject.js +++ b/isObject.js @@ -2,7 +2,7 @@ define([], function() { /** * Checks if `value` is the - * [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types) + * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) * * @static diff --git a/isPlainObject.js b/isPlainObject.js index b97a432a8..a13e826a9 100644 --- a/isPlainObject.js +++ b/isPlainObject.js @@ -17,7 +17,7 @@ define(['./_getPrototype', './_isHostObject', './isObjectLike'], function(getPro /** * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var objectToString = objectProto.toString; @@ -31,8 +31,7 @@ define(['./_getPrototype', './_isHostObject', './isObjectLike'], function(getPro * @since 0.8.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a plain object, - * else `false`. + * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. * @example * * function Foo() { diff --git a/isSafeInteger.js b/isSafeInteger.js index 595a66987..34402dd99 100644 --- a/isSafeInteger.js +++ b/isSafeInteger.js @@ -15,8 +15,7 @@ define(['./isInteger'], function(isInteger) { * @since 4.0.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a safe integer, - * else `false`. + * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`. * @example * * _.isSafeInteger(3); diff --git a/isString.js b/isString.js index 4ab503f7c..da7c60bc5 100644 --- a/isString.js +++ b/isString.js @@ -8,7 +8,7 @@ define(['./isArray', './isObjectLike'], function(isArray, isObjectLike) { /** * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var objectToString = objectProto.toString; diff --git a/isSymbol.js b/isSymbol.js index da9d9856f..0d14ec7b1 100644 --- a/isSymbol.js +++ b/isSymbol.js @@ -8,7 +8,7 @@ define(['./isObjectLike'], function(isObjectLike) { /** * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var objectToString = objectProto.toString; diff --git a/isWeakSet.js b/isWeakSet.js index bd594cde8..cfc56a646 100644 --- a/isWeakSet.js +++ b/isWeakSet.js @@ -8,7 +8,7 @@ define(['./isObjectLike'], function(isObjectLike) { /** * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var objectToString = objectProto.toString; diff --git a/keys.js b/keys.js index 5cdee8055..912be530a 100644 --- a/keys.js +++ b/keys.js @@ -1,10 +1,10 @@ -define(['./_baseHas', './_baseKeys', './_indexKeys', './isArrayLike', './_isIndex', './_isPrototype'], function(baseHas, baseKeys, indexKeys, isArrayLike, isIndex, isPrototype) { +define(['./_arrayLikeKeys', './_baseKeys', './isArrayLike'], function(arrayLikeKeys, baseKeys, isArrayLike) { /** * Creates an array of the own enumerable property names of `object`. * * **Note:** Non-object values are coerced to objects. See the - * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys) + * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) * for more details. * * @static @@ -29,23 +29,7 @@ define(['./_baseHas', './_baseKeys', './_indexKeys', './isArrayLike', './_isInde * // => ['0', '1'] */ function keys(object) { - var isProto = isPrototype(object); - if (!(isProto || isArrayLike(object))) { - return baseKeys(object); - } - var indexes = indexKeys(object), - skipIndexes = !!indexes, - result = indexes || [], - length = result.length; - - for (var key in object) { - if (baseHas(object, key) && - !(skipIndexes && (key == 'length' || isIndex(key, length))) && - !(isProto && key == 'constructor')) { - result.push(key); - } - } - return result; + return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); } return keys; diff --git a/keysIn.js b/keysIn.js index 879dfe9ac..2e0985bd1 100644 --- a/keysIn.js +++ b/keysIn.js @@ -1,10 +1,4 @@ -define(['./_baseKeysIn', './_indexKeys', './_isIndex', './_isPrototype'], function(baseKeysIn, indexKeys, isIndex, isPrototype) { - - /** Used for built-in method references. */ - var objectProto = Object.prototype; - - /** Used to check objects for own properties. */ - var hasOwnProperty = objectProto.hasOwnProperty; +define(['./_arrayLikeKeys', './_baseKeysIn', './isArrayLike'], function(arrayLikeKeys, baseKeysIn, isArrayLike) { /** * Creates an array of the own and inherited enumerable property names of `object`. @@ -30,23 +24,7 @@ define(['./_baseKeysIn', './_indexKeys', './_isIndex', './_isPrototype'], functi * // => ['a', 'b', 'c'] (iteration order is not guaranteed) */ function keysIn(object) { - var index = -1, - isProto = isPrototype(object), - props = baseKeysIn(object), - propsLength = props.length, - indexes = indexKeys(object), - skipIndexes = !!indexes, - result = indexes || [], - length = result.length; - - while (++index < propsLength) { - var key = props[index]; - if (!(skipIndexes && (key == 'length' || isIndex(key, length))) && - !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { - result.push(key); - } - } - return result; + return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); } return keysIn; diff --git a/main.js b/main.js index c9c37e6a7..021fdd391 100644 --- a/main.js +++ b/main.js @@ -13,7 +13,7 @@ var undefined; /** Used as the semantic version number. */ - var VERSION = '4.14.1'; + var VERSION = '4.14.2'; /** Used as the size to enable large array optimizations. */ var LARGE_ARRAY_SIZE = 200; @@ -135,7 +135,7 @@ /** * Used to match `RegExp` - * [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns). + * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). */ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, reHasRegExpChar = RegExp(reRegExpChar.source); @@ -158,7 +158,7 @@ /** * Used to match - * [ES template delimiters](http://ecma-international.org/ecma-262/6.0/#sec-template-literal-lexical-components). + * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components). */ var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; @@ -267,9 +267,9 @@ var contextProps = [ 'Array', 'Buffer', 'DataView', 'Date', 'Error', 'Float32Array', 'Float64Array', 'Function', 'Int8Array', 'Int16Array', 'Int32Array', 'Map', 'Math', 'Object', - 'Promise', 'Reflect', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', - 'Uint8Array', 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', - '_', 'clearTimeout', 'isFinite', 'parseInt', 'setTimeout' + 'Promise', 'RegExp', 'Set', 'String', 'Symbol', 'TypeError', 'Uint8Array', + 'Uint8ClampedArray', 'Uint16Array', 'Uint32Array', 'WeakMap', '_', 'clearTimeout', + 'isFinite', 'parseInt', 'setTimeout' ]; /** Used to make template sourceURLs easier to identify. */ @@ -1130,7 +1130,7 @@ } /** - * Creates a function that invokes `func` with its first argument transformed. + * Creates a unary function that invokes `func` with its argument transformed. * * @private * @param {Function} func The function to wrap. @@ -1283,7 +1283,6 @@ /** Built-in constructor references. */ var Array = context.Array, - Date = context.Date, Error = context.Error, Math = context.Math, RegExp = context.RegExp, @@ -1317,7 +1316,7 @@ /** * Used to resolve the - * [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) + * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring) * of values. */ var objectToString = objectProto.toString; @@ -1333,29 +1332,28 @@ /** Built-in value references. */ var Buffer = moduleExports ? context.Buffer : undefined, - Reflect = context.Reflect, Symbol = context.Symbol, Uint8Array = context.Uint8Array, - enumerate = Reflect ? Reflect.enumerate : undefined, + getPrototype = overArg(Object.getPrototypeOf, Object), iteratorSymbol = Symbol ? Symbol.iterator : undefined, objectCreate = context.Object.create, propertyIsEnumerable = objectProto.propertyIsEnumerable, splice = arrayProto.splice, spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined; - /** Built-in method references that are mockable. */ - var clearTimeout = function(id) { return context.clearTimeout.call(root, id); }, - setTimeout = function(func, wait) { return context.setTimeout.call(root, func, wait); }; + /** Mocked built-ins. */ + var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, + ctxNow = context.Date && context.Date.now !== root.Date.now && context.Date.now, + ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout; /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeCeil = Math.ceil, nativeFloor = Math.floor, - nativeGetPrototype = Object.getPrototypeOf, nativeGetSymbols = Object.getOwnPropertySymbols, nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined, nativeIsFinite = context.isFinite, nativeJoin = arrayProto.join, - nativeKeys = Object.keys, + nativeKeys = overArg(Object.keys, Object), nativeMax = Math.max, nativeMin = Math.min, nativeParseInt = context.parseInt, @@ -2202,6 +2200,31 @@ /*------------------------------------------------------------------------*/ + /** + * Creates an array of the enumerable property names of the array-like `value`. + * + * @private + * @param {*} value The value to query. + * @param {boolean} inherited Specify returning inherited property names. + * @returns {Array} Returns the array of property names. + */ + function arrayLikeKeys(value, inherited) { + var result = (isArray(value) || isString(value) || isArguments(value)) + ? baseTimes(value.length, String) + : []; + + var length = result.length, + skipIndexes = !!length; + + for (var key in value) { + if ((inherited || hasOwnProperty.call(value, key)) && + !(skipIndexes && (key == 'length' || isIndex(key, length)))) { + result.push(key); + } + } + return result; + } + /** * Used by `_.defaults` to customize its `_.assignIn` use. * @@ -2238,7 +2261,7 @@ /** * Assigns `value` to `key` of `object` if the existing value is not equivalent - * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons. * * @private @@ -2446,14 +2469,13 @@ if (object == null) { return !length; } - var index = length; - while (index--) { - var key = props[index], + object = Object(object); + while (length--) { + var key = props[length], predicate = source[key], value = object[key]; - if ((value === undefined && - !(key in Object(object))) || !predicate(value)) { + if ((value === undefined && !(key in object)) || !predicate(value)) { return false; } } @@ -2480,7 +2502,7 @@ * @param {Function} func The function to delay. * @param {number} wait The number of milliseconds to delay invocation. * @param {Array} args The arguments to provide to `func`. - * @returns {number} Returns the timer id. + * @returns {number|Object} Returns the timer id or timeout object. */ function baseDelay(func, wait, args) { if (typeof func != 'function') { @@ -2825,12 +2847,7 @@ * @returns {boolean} Returns `true` if `key` exists, else `false`. */ function baseHas(object, key) { - // Avoid a bug in IE 10-11 where objects with a [[Prototype]] of `null`, - // that are composed entirely of index properties, return `false` for - // `hasOwnProperty` checks of them. - return object != null && - (hasOwnProperty.call(object, key) || - (typeof object == 'object' && key in object && getPrototype(object) === null)); + return object != null && hasOwnProperty.call(object, key); } /** @@ -3204,40 +3221,47 @@ } /** - * The base implementation of `_.keys` which doesn't skip the constructor - * property of prototypes or treat sparse arrays as dense. + * The base implementation of `_.keys` which doesn't treat sparse arrays as dense. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of property names. */ - var baseKeys = overArg(nativeKeys, Object); + function baseKeys(object) { + if (!isPrototype(object)) { + return nativeKeys(object); + } + var result = []; + for (var key in Object(object)) { + if (hasOwnProperty.call(object, key) && key != 'constructor') { + result.push(key); + } + } + return result; + } /** - * The base implementation of `_.keysIn` which doesn't skip the constructor - * property of prototypes or treat sparse arrays as dense. + * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense. * * @private * @param {Object} object The object to query. * @returns {Array} Returns the array of property names. */ function baseKeysIn(object) { - object = object == null ? object : Object(object); + if (!isObject(object)) { + return nativeKeysIn(object); + } + var isProto = isPrototype(object), + result = []; - var result = []; for (var key in object) { - result.push(key); + if (!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { + result.push(key); + } } return result; } - // Fallback for IE < 9 with es6-shim. - if (enumerate && !propertyIsEnumerable.call({ 'valueOf': 1 }, 'valueOf')) { - baseKeysIn = function(object) { - return iteratorToArray(enumerate(object)); - }; - } - /** * The base implementation of `_.lt` which doesn't coerce arguments. * @@ -3322,7 +3346,7 @@ return; } if (!(isArray(source) || isTypedArray(source))) { - var props = keysIn(source); + var props = baseKeysIn(source); } arrayEach(props || source, function(srcValue, key) { if (props) { @@ -3689,6 +3713,9 @@ * @returns {Object} Returns `object`. */ function baseSet(object, path, value, customizer) { + if (!isObject(object)) { + return object; + } path = isKey(path, object) ? [path] : castPath(path); var index = -1, @@ -3697,20 +3724,19 @@ nested = object; while (nested != null && ++index < length) { - var key = toKey(path[index]); - if (isObject(nested)) { - var newValue = value; - if (index != lastIndex) { - var objValue = nested[key]; - newValue = customizer ? customizer(objValue, key, nested) : undefined; - if (newValue === undefined) { - newValue = objValue == null - ? (isIndex(path[index + 1]) ? [] : {}) - : objValue; - } + var key = toKey(path[index]), + newValue = value; + + if (index != lastIndex) { + var objValue = nested[key]; + newValue = customizer ? customizer(objValue, key, nested) : undefined; + if (newValue === undefined) { + newValue = isObject(objValue) + ? objValue + : (isIndex(path[index + 1]) ? [] : {}); } - assignValue(nested, key, newValue); } + assignValue(nested, key, newValue); nested = nested[key]; } return object; @@ -4003,7 +4029,7 @@ object = parent(object, path); var key = toKey(last(path)); - return !(object != null && baseHas(object, key)) || delete object[key]; + return !(object != null && hasOwnProperty.call(object, key)) || delete object[key]; } /** @@ -4158,6 +4184,16 @@ return (!start && end >= length) ? array : baseSlice(array, start, end); } + /** + * A simple wrapper around the global [`clearTimeout`](https://mdn.io/clearTimeout). + * + * @private + * @param {number|Object} id The timer id or timeout object of the timer to clear. + */ + var clearTimeout = ctxClearTimeout || function(id) { + return root.clearTimeout(id); + }; + /** * Creates a clone of `buffer`. * @@ -4651,7 +4687,7 @@ function createCtor(Ctor) { return function() { // Use a `switch` statement to work with class constructors. See - // http://ecma-international.org/ecma-262/6.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist + // http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist // for more details. var args = arguments; switch (args.length) { @@ -5339,7 +5375,7 @@ case regexpTag: case stringTag: // Coerce regexes to strings and treat strings, primitives and objects, - // as equal. See http://www.ecma-international.org/ecma-262/6.0/#sec-regexp.prototype.tostring + // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring // for more details. return object == (other + ''); @@ -5401,7 +5437,7 @@ var index = objLength; while (index--) { var key = objProps[index]; - if (!(isPartial ? key in other : baseHas(other, key))) { + if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) { return false; } } @@ -5537,19 +5573,6 @@ return arguments.length ? result(arguments[0], arguments[1]) : result; } - /** - * Gets the "length" property value of `object`. - * - * **Note:** This function is used to avoid a - * [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) that affects - * Safari on at least iOS 8.1-8.3 ARM64. - * - * @private - * @param {Object} object The object to query. - * @returns {*} Returns the "length" value. - */ - var getLength = baseProperty('length'); - /** * Gets the data for `map`. * @@ -5598,15 +5621,6 @@ return baseIsNative(value) ? value : undefined; } - /** - * Gets the `[[Prototype]]` of `value`. - * - * @private - * @param {*} value The value to query. - * @returns {null|Object} Returns the `[[Prototype]]`. - */ - var getPrototype = overArg(nativeGetPrototype, Object); - /** * Creates an array of the own enumerable symbol properties of `object`. * @@ -5819,23 +5833,6 @@ } } - /** - * Creates an array of index keys for `object` values of arrays, - * `arguments` objects, and strings, otherwise `null` is returned. - * - * @private - * @param {Object} object The object to query. - * @returns {Array|null} Returns index keys, else `null`. - */ - function indexKeys(object) { - var length = object ? object.length : undefined; - if (isLength(length) && - (isArray(object) || isString(object) || isArguments(object))) { - return baseTimes(length, String); - } - return null; - } - /** * Inserts wrapper `details` in a comment at the top of the `source` body. * @@ -6120,6 +6117,25 @@ return objValue; } + /** + * This function is like + * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) + * except that it includes inherited enumerable properties. + * + * @private + * @param {Object} object The object to query. + * @returns {Array} Returns the array of property names. + */ + function nativeKeysIn(object) { + var result = []; + if (object != null) { + for (var key in Object(object)) { + result.push(key); + } + } + return result; + } + /** * Gets the parent value at `path` of `object`. * @@ -6188,6 +6204,18 @@ }; }()); + /** + * A simple wrapper around the global [`setTimeout`](https://mdn.io/setTimeout). + * + * @private + * @param {Function} func The function to delay. + * @param {number} wait The number of milliseconds to delay invocation. + * @returns {number|Object} Returns the timer id or timeout object. + */ + var setTimeout = ctxSetTimeout || function(func, wait) { + return root.setTimeout(func, wait); + }; + /** * Sets the `toString` method of `wrapper` to mimic the source of `reference` * with wrapper details in a comment at the top of the source body. @@ -6408,7 +6436,7 @@ /** * Creates an array of `array` values not included in the other given arrays - * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons. The order of result values is determined by the * order they occur in the first array. * @@ -6911,7 +6939,7 @@ /** * Gets the index at which the first occurrence of `value` is found in `array` - * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons. If `fromIndex` is negative, it's used as the * offset from the end of `array`. * @@ -6959,12 +6987,13 @@ * // => [1, 2] */ function initial(array) { - return dropRight(array, 1); + var length = array ? array.length : 0; + return length ? baseSlice(array, 0, -1) : []; } /** * Creates an array of unique values that are included in all given arrays - * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons. The order of result values is determined by the * order they occur in the first array. * @@ -7168,7 +7197,7 @@ /** * Removes all given values from `array` using - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons. * * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove` @@ -7637,7 +7666,8 @@ * // => [2, 3] */ function tail(array) { - return drop(array, 1); + var length = array ? array.length : 0; + return length ? baseSlice(array, 1, length) : []; } /** @@ -7794,7 +7824,7 @@ /** * Creates an array of unique values, in order, from all given arrays using - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons. * * @static @@ -7875,7 +7905,7 @@ /** * Creates a duplicate-free version of an array, using - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons, in which only the first occurrence of each * element is kept. * @@ -8020,7 +8050,7 @@ /** * Creates an array excluding all given values using - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons. * * **Note:** Unlike `_.pull`, this method returns a new array. @@ -8591,6 +8621,11 @@ * Iteration is stopped once `predicate` returns falsey. The predicate is * invoked with three arguments: (value, index|key, collection). * + * **Note:** This method returns `true` for + * [empty collections](https://en.wikipedia.org/wiki/Empty_set) because + * [everything is true](https://en.wikipedia.org/wiki/Vacuous_truth) of + * elements of empty collections. + * * @static * @memberOf _ * @since 0.1.0 @@ -8908,7 +8943,7 @@ /** * Checks if `value` is in `collection`. If `collection` is a string, it's * checked for a substring of `value`, otherwise - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * is used for equality comparisons. If `fromIndex` is negative, it's used as * the offset from the end of `collection`. * @@ -9376,7 +9411,7 @@ return collection.size; } } - return keys(collection).length; + return baseKeys(collection).length; } /** @@ -9488,9 +9523,9 @@ * }, _.now()); * // => Logs the number of milliseconds it took for the deferred invocation. */ - function now() { - return Date.now(); - } + var now = ctxNow || function() { + return root.Date.now(); + }; /*------------------------------------------------------------------------*/ @@ -10031,7 +10066,7 @@ * **Note:** The cache is exposed as the `cache` property on the memoized * function. Its creation may be customized by replacing the `_.memoize.Cache` * constructor with one whose instances implement the - * [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object) + * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) * method interface of `delete`, `get`, `has`, and `set`. * * @static @@ -10331,7 +10366,7 @@ /** * Creates a function that invokes `func` with the `this` binding of the * create function and an array of arguments much like - * [`Function#apply`](http://www.ecma-international.org/ecma-262/6.0/#sec-function.prototype.apply). + * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply). * * **Note:** This method is based on the * [spread operator](https://mdn.io/spread_operator). @@ -10678,7 +10713,7 @@ /** * Performs a - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * comparison between two values to determine if they are equivalent. * * @static @@ -10858,7 +10893,7 @@ * // => false */ function isArrayLike(value) { - return value != null && isLength(getLength(value)) && !isFunction(value); + return value != null && isLength(value.length) && !isFunction(value); } /** @@ -10958,8 +10993,7 @@ * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a DOM element, - * else `false`. + * @returns {boolean} Returns `true` if `value` is a DOM element, else `false`. * @example * * _.isElement(document.body); @@ -11017,12 +11051,14 @@ return !value.size; } } + var isProto = isPrototype(value); for (var key in value) { - if (hasOwnProperty.call(value, key)) { + if (hasOwnProperty.call(value, key) && + !(isProto && key == 'constructor')) { return false; } } - return !(nonEnumShadows && keys(value).length); + return !(nonEnumShadows && nativeKeys(value).length); } /** @@ -11041,8 +11077,7 @@ * @category Lang * @param {*} value The value to compare. * @param {*} other The other value to compare. - * @returns {boolean} Returns `true` if the values are equivalent, - * else `false`. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. * @example * * var object = { 'a': 1 }; @@ -11071,8 +11106,7 @@ * @param {*} value The value to compare. * @param {*} other The other value to compare. * @param {Function} [customizer] The function to customize comparisons. - * @returns {boolean} Returns `true` if the values are equivalent, - * else `false`. + * @returns {boolean} Returns `true` if the values are equivalent, else `false`. * @example * * function isGreeting(value) { @@ -11106,8 +11140,7 @@ * @since 3.0.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is an error object, - * else `false`. + * @returns {boolean} Returns `true` if `value` is an error object, else `false`. * @example * * _.isError(new Error); @@ -11135,8 +11168,7 @@ * @since 0.1.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a finite number, - * else `false`. + * @returns {boolean} Returns `true` if `value` is a finite number, else `false`. * @example * * _.isFinite(3); @@ -11213,16 +11245,15 @@ /** * Checks if `value` is a valid array-like length. * - * **Note:** This function is loosely based on - * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). + * **Note:** This method is loosely based on + * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). * * @static * @memberOf _ * @since 4.0.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a valid length, - * else `false`. + * @returns {boolean} Returns `true` if `value` is a valid length, else `false`. * @example * * _.isLength(3); @@ -11244,7 +11275,7 @@ /** * Checks if `value` is the - * [language type](http://www.ecma-international.org/ecma-262/6.0/#sec-ecmascript-language-types) + * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types) * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`) * * @static @@ -11323,8 +11354,12 @@ * Performs a partial deep comparison between `object` and `source` to * determine if `object` contains equivalent property values. * - * **Note:** This method supports comparing the same values as `_.isEqual` - * and is equivalent to `_.matches` when `source` is partially applied. + * **Note:** This method is equivalent to `_.matches` when `source` is + * partially applied. + * + * Partial comparisons will match empty array and empty object `source` + * values against any array or object value, respectively. See `_.isEqual` + * for a list of supported value comparisons. * * @static * @memberOf _ @@ -11537,8 +11572,7 @@ * @since 0.8.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a plain object, - * else `false`. + * @returns {boolean} Returns `true` if `value` is a plain object, else `false`. * @example * * function Foo() { @@ -11602,8 +11636,7 @@ * @since 4.0.0 * @category Lang * @param {*} value The value to check. - * @returns {boolean} Returns `true` if `value` is a safe integer, - * else `false`. + * @returns {boolean} Returns `true` if `value` is a safe integer, else `false`. * @example * * _.isSafeInteger(3); @@ -11897,7 +11930,7 @@ * Converts `value` to an integer. * * **Note:** This method is loosely based on - * [`ToInteger`](http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger). + * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). * * @static * @memberOf _ @@ -11931,7 +11964,7 @@ * array-like object. * * **Note:** This method is based on - * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). + * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). * * @static * @memberOf _ @@ -12160,13 +12193,7 @@ * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4 } */ var assignIn = createAssigner(function(object, source) { - if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) { - copyObject(source, keysIn(source), object); - return; - } - for (var key in source) { - assignValue(object, key, source[key]); - } + copyObject(source, keysIn(source), object); }); /** @@ -12775,7 +12802,7 @@ * Creates an array of the own enumerable property names of `object`. * * **Note:** Non-object values are coerced to objects. See the - * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys) + * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys) * for more details. * * @static @@ -12800,23 +12827,7 @@ * // => ['0', '1'] */ function keys(object) { - var isProto = isPrototype(object); - if (!(isProto || isArrayLike(object))) { - return baseKeys(object); - } - var indexes = indexKeys(object), - skipIndexes = !!indexes, - result = indexes || [], - length = result.length; - - for (var key in object) { - if (baseHas(object, key) && - !(skipIndexes && (key == 'length' || isIndex(key, length))) && - !(isProto && key == 'constructor')) { - result.push(key); - } - } - return result; + return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object); } /** @@ -12843,23 +12854,7 @@ * // => ['a', 'b', 'c'] (iteration order is not guaranteed) */ function keysIn(object) { - var index = -1, - isProto = isPrototype(object), - props = baseKeysIn(object), - propsLength = props.length, - indexes = indexKeys(object), - skipIndexes = !!indexes, - result = indexes || [], - length = result.length; - - while (++index < propsLength) { - var key = props[index]; - if (!(skipIndexes && (key == 'length' || isIndex(key, length))) && - !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) { - result.push(key); - } - } - return result; + return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object); } /** @@ -15039,8 +15034,12 @@ * object and `source`, returning `true` if the given object has equivalent * property values, else `false`. * - * **Note:** The created function supports comparing the same values as - * `_.isEqual` is equivalent to `_.isMatch` with `source` partially applied. + * **Note:** The created function is equivalent to `_.isMatch` with `source` + * partially applied. + * + * Partial comparisons will match empty array and empty object `source` + * values against any array or object value, respectively. See `_.isEqual` + * for a list of supported value comparisons. * * @static * @memberOf _ @@ -15067,7 +15066,9 @@ * value at `path` of a given object to `srcValue`, returning `true` if the * object value is equivalent, else `false`. * - * **Note:** This method supports comparing the same values as `_.isEqual`. + * **Note:** Partial comparisons will match empty array and empty object + * `srcValue` values against any array or object value, respectively. See + * `_.isEqual` for a list of supported value comparisons. * * @static * @memberOf _ diff --git a/matches.js b/matches.js index 86bdf909e..03d4278b5 100644 --- a/matches.js +++ b/matches.js @@ -5,8 +5,12 @@ define(['./_baseClone', './_baseMatches'], function(baseClone, baseMatches) { * object and `source`, returning `true` if the given object has equivalent * property values, else `false`. * - * **Note:** The created function supports comparing the same values as - * `_.isEqual` is equivalent to `_.isMatch` with `source` partially applied. + * **Note:** The created function is equivalent to `_.isMatch` with `source` + * partially applied. + * + * Partial comparisons will match empty array and empty object `source` + * values against any array or object value, respectively. See `_.isEqual` + * for a list of supported value comparisons. * * @static * @memberOf _ diff --git a/matchesProperty.js b/matchesProperty.js index 930e19eb7..8504ef7c5 100644 --- a/matchesProperty.js +++ b/matchesProperty.js @@ -5,7 +5,9 @@ define(['./_baseClone', './_baseMatchesProperty'], function(baseClone, baseMatch * value at `path` of a given object to `srcValue`, returning `true` if the * object value is equivalent, else `false`. * - * **Note:** This method supports comparing the same values as `_.isEqual`. + * **Note:** Partial comparisons will match empty array and empty object + * `srcValue` values against any array or object value, respectively. See + * `_.isEqual` for a list of supported value comparisons. * * @static * @memberOf _ diff --git a/memoize.js b/memoize.js index 78e008a94..662b748f8 100644 --- a/memoize.js +++ b/memoize.js @@ -13,7 +13,7 @@ define(['./_MapCache'], function(MapCache) { * **Note:** The cache is exposed as the `cache` property on the memoized * function. Its creation may be customized by replacing the `_.memoize.Cache` * constructor with one whose instances implement the - * [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object) + * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) * method interface of `delete`, `get`, `has`, and `set`. * * @static diff --git a/now.js b/now.js index 5c46c2c3d..99c6bb0f8 100644 --- a/now.js +++ b/now.js @@ -1,4 +1,4 @@ -define([], function() { +define(['./_root'], function(root) { /** * Gets the timestamp of the number of milliseconds that have elapsed since @@ -16,9 +16,9 @@ define([], function() { * }, _.now()); * // => Logs the number of milliseconds it took for the deferred invocation. */ - function now() { - return Date.now(); - } + var now = function() { + return root.Date.now(); + }; return now; }); diff --git a/package.json b/package.json index b2d9eeefb..34f2ef2ea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lodash-amd", - "version": "4.14.1", + "version": "4.14.2", "description": "Lodash exported as AMD modules.", "keywords": "amd, modules, stdlib, util", "homepage": "https://lodash.com/custom-builds", diff --git a/pull.js b/pull.js index abdcbdf80..00ca545a3 100644 --- a/pull.js +++ b/pull.js @@ -2,7 +2,7 @@ define(['./_baseRest', './pullAll'], function(baseRest, pullAll) { /** * Removes all given values from `array` using - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons. * * **Note:** Unlike `_.without`, this method mutates `array`. Use `_.remove` diff --git a/size.js b/size.js index 323255d6b..5f6b36d9d 100644 --- a/size.js +++ b/size.js @@ -1,4 +1,4 @@ -define(['./_getTag', './isArrayLike', './isObjectLike', './isString', './keys', './_stringSize'], function(getTag, isArrayLike, isObjectLike, isString, keys, stringSize) { +define(['./_baseKeys', './_getTag', './isArrayLike', './isObjectLike', './isString', './_stringSize'], function(baseKeys, getTag, isArrayLike, isObjectLike, isString, stringSize) { /** `Object#toString` result references. */ var mapTag = '[object Map]', @@ -39,7 +39,7 @@ define(['./_getTag', './isArrayLike', './isObjectLike', './isString', './keys', return collection.size; } } - return keys(collection).length; + return baseKeys(collection).length; } return size; diff --git a/spread.js b/spread.js index 047fa6a7d..a2f2aa758 100644 --- a/spread.js +++ b/spread.js @@ -12,7 +12,7 @@ define(['./_apply', './_arrayPush', './_baseRest', './_castSlice', './toInteger' /** * Creates a function that invokes `func` with the `this` binding of the * create function and an array of arguments much like - * [`Function#apply`](http://www.ecma-international.org/ecma-262/6.0/#sec-function.prototype.apply). + * [`Function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply). * * **Note:** This method is based on the * [spread operator](https://mdn.io/spread_operator). diff --git a/tail.js b/tail.js index 086b8bb05..46081d966 100644 --- a/tail.js +++ b/tail.js @@ -1,4 +1,4 @@ -define(['./drop'], function(drop) { +define(['./_baseSlice'], function(baseSlice) { /** * Gets all but the first element of `array`. @@ -15,7 +15,8 @@ define(['./drop'], function(drop) { * // => [2, 3] */ function tail(array) { - return drop(array, 1); + var length = array ? array.length : 0; + return length ? baseSlice(array, 1, length) : []; } return tail; diff --git a/template.js b/template.js index ee092d695..3325a89fc 100644 --- a/template.js +++ b/template.js @@ -10,7 +10,7 @@ define(['./_assignInDefaults', './assignInWith', './attempt', './_baseValues', ' /** * Used to match - * [ES template delimiters](http://ecma-international.org/ecma-262/6.0/#sec-template-literal-lexical-components). + * [ES template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components). */ var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; diff --git a/toInteger.js b/toInteger.js index e29796b64..ef7e72a2d 100644 --- a/toInteger.js +++ b/toInteger.js @@ -4,7 +4,7 @@ define(['./toFinite'], function(toFinite) { * Converts `value` to an integer. * * **Note:** This method is loosely based on - * [`ToInteger`](http://www.ecma-international.org/ecma-262/6.0/#sec-tointeger). + * [`ToInteger`](http://www.ecma-international.org/ecma-262/7.0/#sec-tointeger). * * @static * @memberOf _ diff --git a/toLength.js b/toLength.js index ca4ed1a99..927e6c298 100644 --- a/toLength.js +++ b/toLength.js @@ -8,7 +8,7 @@ define(['./_baseClamp', './toInteger'], function(baseClamp, toInteger) { * array-like object. * * **Note:** This method is based on - * [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). + * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength). * * @static * @memberOf _ diff --git a/union.js b/union.js index f517eed29..0cdfb0fb9 100644 --- a/union.js +++ b/union.js @@ -2,7 +2,7 @@ define(['./_baseFlatten', './_baseRest', './_baseUniq', './isArrayLikeObject'], /** * Creates an array of unique values, in order, from all given arrays using - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons. * * @static diff --git a/uniq.js b/uniq.js index ec97cafcc..927a24933 100644 --- a/uniq.js +++ b/uniq.js @@ -2,7 +2,7 @@ define(['./_baseUniq'], function(baseUniq) { /** * Creates a duplicate-free version of an array, using - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons, in which only the first occurrence of each * element is kept. * diff --git a/without.js b/without.js index b6dcc53cd..d4545e9d8 100644 --- a/without.js +++ b/without.js @@ -2,7 +2,7 @@ define(['./_baseDifference', './_baseRest', './isArrayLikeObject'], function(bas /** * Creates an array excluding all given values using - * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) + * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero) * for equality comparisons. * * **Note:** Unlike `_.pull`, this method returns a new array.