diff --git a/README.md b/README.md index 5bf134b39..b618f29cc 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# lodash-amd v4.0.0 +# lodash-amd v4.0.1 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.0.0-amd) for more details. +See the [package source](https://github.com/lodash/lodash/tree/4.0.1-amd) for more details. diff --git a/assignInWith.js b/assignInWith.js index 1ef39a573..88ccb8811 100644 --- a/assignInWith.js +++ b/assignInWith.js @@ -27,7 +27,7 @@ define(['./internal/copyObjectWith', './internal/createAssigner', './keysIn'], f * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); * // => { 'a': 1, 'b': 2 } */ - var assignInWith = createAssigner(function(object, source, customizer) { + var assignInWith = createAssigner(function(object, source, srcIndex, customizer) { copyObjectWith(source, keysIn(source), object, customizer); }); diff --git a/assignWith.js b/assignWith.js index da6d87cf4..b285980b4 100644 --- a/assignWith.js +++ b/assignWith.js @@ -26,7 +26,7 @@ define(['./internal/copyObjectWith', './internal/createAssigner', './keys'], fun * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); * // => { 'a': 1, 'b': 2 } */ - var assignWith = createAssigner(function(object, source, customizer) { + var assignWith = createAssigner(function(object, source, srcIndex, customizer) { copyObjectWith(source, keys(source), object, customizer); }); diff --git a/cloneDeepWith.js b/cloneDeepWith.js index 2353e976e..997986599 100644 --- a/cloneDeepWith.js +++ b/cloneDeepWith.js @@ -17,7 +17,7 @@ define(['./internal/baseClone'], function(baseClone) { * } * } * - * var el = _.cloneDeep(document.body, customizer); + * var el = _.cloneDeepWith(document.body, customizer); * * console.log(el === document.body); * // => false diff --git a/cloneWith.js b/cloneWith.js index 81eb832fe..6726f1b39 100644 --- a/cloneWith.js +++ b/cloneWith.js @@ -4,7 +4,7 @@ define(['./internal/baseClone'], function(baseClone) { * This method is like `_.clone` except that it accepts `customizer` which * is invoked to produce the cloned value. If `customizer` returns `undefined` * cloning is handled by the method instead. The `customizer` is invoked with - * up to five arguments; (value [, index|key, object, stack]). + * up to four arguments; (value [, index|key, object, stack]). * * @static * @memberOf _ @@ -20,7 +20,7 @@ define(['./internal/baseClone'], function(baseClone) { * } * } * - * var el = _.clone(document.body, customizer); + * var el = _.cloneWith(document.body, customizer); * * console.log(el === document.body); * // => false diff --git a/concat.js b/concat.js index ee9d66216..79283a8b3 100644 --- a/concat.js +++ b/concat.js @@ -22,8 +22,11 @@ define(['./internal/arrayConcat', './internal/baseFlatten', './isArray', './rest * // => [1] */ var concat = rest(function(array, values) { + if (!isArray(array)) { + array = array == null ? [] : [Object(array)]; + } values = baseFlatten(values); - return arrayConcat(isArray(array) ? array : [Object(array)], values); + return arrayConcat(array, values); }); return concat; diff --git a/cond.js b/cond.js index 0b8aebca1..5e885f63d 100644 --- a/cond.js +++ b/cond.js @@ -20,7 +20,7 @@ define(['./internal/apply', './internal/arrayMap', './internal/baseIteratee', '. * [_.matches({ 'a': 1 }), _.constant('matches A')], * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')], * [_.constant(true), _.constant('no match')] - * ]) + * ]); * * func({ 'a': 1, 'b': 2 }); * // => 'matches A' diff --git a/countBy.js b/countBy.js index 676508329..bc3c72e51 100644 --- a/countBy.js +++ b/countBy.js @@ -16,7 +16,7 @@ define(['./internal/createAggregator'], function(createAggregator) { * @memberOf _ * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Function|Object|string} [iteratee=_.identity] The iteratee to transform keys. * @returns {Object} Returns the composed aggregate object. * @example * diff --git a/deburr.js b/deburr.js index 3e709fdd1..989209e66 100644 --- a/deburr.js +++ b/deburr.js @@ -4,12 +4,16 @@ define(['./internal/deburrLetter', './toString'], function(deburrLetter, toStrin var reLatin1 = /[\xc0-\xd6\xd8-\xde\xdf-\xf6\xf8-\xff]/g; /** Used to compose unicode character classes. */ - var rsComboRange = '\\u0300-\\u036f\\ufe20-\\ufe23'; + var rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23', + rsComboSymbolsRange = '\\u20d0-\\u20f0'; /** Used to compose unicode capture groups. */ - var rsCombo = '[' + rsComboRange + ']'; + var rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']'; - /** Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). */ + /** + * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and + * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). + */ var reComboMark = RegExp(rsCombo, 'g'); /** diff --git a/extend.js b/extend.js new file mode 100644 index 000000000..feed7b62e --- /dev/null +++ b/extend.js @@ -0,0 +1,3 @@ +define(["./assignIn"], function(assignIn) { + return assignIn; +}); diff --git a/extendWith.js b/extendWith.js new file mode 100644 index 000000000..7c31db4ac --- /dev/null +++ b/extendWith.js @@ -0,0 +1,3 @@ +define(["./assignInWith"], function(assignInWith) { + return assignInWith; +}); diff --git a/fromPairs.js b/fromPairs.js index 4672204cd..c547710f6 100644 --- a/fromPairs.js +++ b/fromPairs.js @@ -1,4 +1,4 @@ -define(['./internal/baseSet'], function(baseSet) { +define([], function() { /** * The inverse of `_.toPairs`; this method returns an object composed @@ -21,7 +21,7 @@ define(['./internal/baseSet'], function(baseSet) { while (++index < length) { var pair = pairs[index]; - baseSet(result, pair[0], pair[1]); + result[pair[0]] = pair[1]; } return result; } diff --git a/groupBy.js b/groupBy.js index 32570952e..68a972b44 100644 --- a/groupBy.js +++ b/groupBy.js @@ -9,14 +9,14 @@ define(['./internal/createAggregator'], function(createAggregator) { /** * Creates an object composed of keys generated from the results of running * each element of `collection` through `iteratee`. The corresponding value - * of each key is an array of the elements responsible for generating the key. + * of each key is an array of elements responsible for generating the key. * The iteratee is invoked with one argument: (value). * * @static * @memberOf _ * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Function|Object|string} [iteratee=_.identity] The iteratee to transform keys. * @returns {Object} Returns the composed aggregate object. * @example * diff --git a/internal/_Symbol.js b/internal/Symbol.js similarity index 62% rename from internal/_Symbol.js rename to internal/Symbol.js index 4811a706b..5f1ba58e2 100644 --- a/internal/_Symbol.js +++ b/internal/Symbol.js @@ -1,7 +1,7 @@ define(['./root'], function(root) { /** Built-in value references. */ - var _Symbol = root.Symbol; + var Symbol = root.Symbol; - return _Symbol; + return Symbol; }); diff --git a/internal/arrayReduce.js b/internal/arrayReduce.js index 9d31e83c8..1ea0a59f9 100644 --- a/internal/arrayReduce.js +++ b/internal/arrayReduce.js @@ -8,14 +8,14 @@ define([], function() { * @param {Array} array The array to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {*} [accumulator] The initial value. - * @param {boolean} [initFromArray] Specify using the first element of `array` as the initial value. + * @param {boolean} [initAccum] Specify using the first element of `array` as the initial value. * @returns {*} Returns the accumulated value. */ - function arrayReduce(array, iteratee, accumulator, initFromArray) { + function arrayReduce(array, iteratee, accumulator, initAccum) { var index = -1, length = array.length; - if (initFromArray && length) { + if (initAccum && length) { accumulator = array[++index]; } while (++index < length) { diff --git a/internal/arrayReduceRight.js b/internal/arrayReduceRight.js index 01d93b792..ee1e346b5 100644 --- a/internal/arrayReduceRight.js +++ b/internal/arrayReduceRight.js @@ -8,12 +8,12 @@ define([], function() { * @param {Array} array The array to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {*} [accumulator] The initial value. - * @param {boolean} [initFromArray] Specify using the last element of `array` as the initial value. + * @param {boolean} [initAccum] Specify using the last element of `array` as the initial value. * @returns {*} Returns the accumulated value. */ - function arrayReduceRight(array, iteratee, accumulator, initFromArray) { + function arrayReduceRight(array, iteratee, accumulator, initAccum) { var length = array.length; - if (initFromArray && length) { + if (initAccum && length) { accumulator = array[--length]; } while (length--) { diff --git a/internal/baseFind.js b/internal/baseFind.js index 8bbf9c3cb..b229efce4 100644 --- a/internal/baseFind.js +++ b/internal/baseFind.js @@ -3,7 +3,7 @@ define([], function() { /** * The base implementation of methods like `_.find` and `_.findKey`, without * support for iteratee shorthands, which iterates over `collection` using - * the provided `eachFunc`. + * `eachFunc`. * * @private * @param {Array|Object} collection The collection to search. diff --git a/internal/baseInvoke.js b/internal/baseInvoke.js index f71133700..ec9f1c740 100644 --- a/internal/baseInvoke.js +++ b/internal/baseInvoke.js @@ -7,7 +7,6 @@ define(['./apply', './baseToPath', './isKey', '../last', './parent'], function(a * The base implementation of `_.invoke` without support for individual * method arguments. * - * * @private * @param {Object} object The object to query. * @param {Array|string} path The path of the method to invoke. diff --git a/internal/baseIsMatch.js b/internal/baseIsMatch.js index 94329c4fb..038ac7284 100644 --- a/internal/baseIsMatch.js +++ b/internal/baseIsMatch.js @@ -49,7 +49,10 @@ define(['./Stack', './baseIsEqual'], function(Stack, baseIsEqual) { var stack = new Stack, result = customizer ? customizer(objValue, srcValue, key, object, source, stack) : undefined; - if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack) : result)) { + if (!(result === undefined + ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack) + : result + )) { return false; } } diff --git a/internal/baseMerge.js b/internal/baseMerge.js index 918cbe8ab..0cefe3e85 100644 --- a/internal/baseMerge.js +++ b/internal/baseMerge.js @@ -9,10 +9,11 @@ define(['./Stack', './arrayEach', './assignMergeValue', './baseMergeDeep', '../i * @private * @param {Object} object The destination object. * @param {Object} source The source object. + * @param {number} srcIndex The index of `source`. * @param {Function} [customizer] The function to customize merged values. * @param {Object} [stack] Tracks traversed source values and their merged counterparts. */ - function baseMerge(object, source, customizer, stack) { + function baseMerge(object, source, srcIndex, customizer, stack) { if (object === source) { return; } @@ -24,7 +25,7 @@ define(['./Stack', './arrayEach', './assignMergeValue', './baseMergeDeep', '../i } if (isObject(srcValue)) { stack || (stack = new Stack); - baseMergeDeep(object, source, key, baseMerge, customizer, stack); + baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); } else { var newValue = customizer ? customizer(object[key], srcValue, (key + ''), object, source, stack) : undefined; diff --git a/internal/baseMergeDeep.js b/internal/baseMergeDeep.js index 4d73962da..0b31bb258 100644 --- a/internal/baseMergeDeep.js +++ b/internal/baseMergeDeep.js @@ -12,11 +12,12 @@ define(['./assignMergeValue', './baseClone', './copyArray', '../isArguments', '. * @param {Object} object The destination object. * @param {Object} source The source object. * @param {string} key The key of the value to merge. + * @param {number} srcIndex The index of `source`. * @param {Function} mergeFunc The function to merge values. * @param {Function} [customizer] The function to customize assigned values. * @param {Object} [stack] Tracks traversed source values and their merged counterparts. */ - function baseMergeDeep(object, source, key, mergeFunc, customizer, stack) { + function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { var objValue = object[key], srcValue = source[key], stacked = stack.get(srcValue) || stack.get(objValue); @@ -31,24 +32,36 @@ define(['./assignMergeValue', './baseClone', './copyArray', '../isArguments', '. if (isCommon) { newValue = srcValue; if (isArray(srcValue) || isTypedArray(srcValue)) { - newValue = isArray(objValue) - ? objValue - : ((isArrayLikeObject(objValue)) ? copyArray(objValue) : baseClone(srcValue)); + if (isArray(objValue)) { + newValue = srcIndex ? copyArray(objValue) : objValue; + } + else if (isArrayLikeObject(objValue)) { + newValue = copyArray(objValue); + } + else { + newValue = baseClone(srcValue); + } } else if (isPlainObject(srcValue) || isArguments(srcValue)) { - newValue = isArguments(objValue) - ? toPlainObject(objValue) - : (isObject(objValue) ? objValue : baseClone(srcValue)); + if (isArguments(objValue)) { + newValue = toPlainObject(objValue); + } + else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) { + newValue = baseClone(srcValue); + } + else { + newValue = srcIndex ? baseClone(objValue) : objValue; + } } else { - isCommon = isFunction(srcValue); + isCommon = false; } } stack.set(srcValue, newValue); if (isCommon) { // Recursively merge objects and arrays (susceptible to call stack limits). - mergeFunc(newValue, srcValue, customizer, stack); + mergeFunc(newValue, srcValue, srcIndex, customizer, stack); } assignMergeValue(object, key, newValue); } diff --git a/internal/basePickBy.js b/internal/basePickBy.js index ccd1a8124..93fd3b28e 100644 --- a/internal/basePickBy.js +++ b/internal/basePickBy.js @@ -11,7 +11,7 @@ define(['./baseForIn'], function(baseForIn) { function basePickBy(object, predicate) { var result = {}; baseForIn(object, function(value, key) { - if (predicate(value)) { + if (predicate(value, key)) { result[key] = value; } }); diff --git a/internal/baseReduce.js b/internal/baseReduce.js index 54391879f..cd82fa0d0 100644 --- a/internal/baseReduce.js +++ b/internal/baseReduce.js @@ -2,21 +2,20 @@ define([], function() { /** * The base implementation of `_.reduce` and `_.reduceRight`, without support - * for iteratee shorthands, which iterates over `collection` using the provided - * `eachFunc`. + * for iteratee shorthands, which iterates over `collection` using `eachFunc`. * * @private * @param {Array|Object} collection The collection to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {*} accumulator The initial value. - * @param {boolean} initFromCollection Specify using the first or last element of `collection` as the initial value. + * @param {boolean} initAccum Specify using the first or last element of `collection` as the initial value. * @param {Function} eachFunc The function to iterate over `collection`. * @returns {*} Returns the accumulated value. */ - function baseReduce(collection, iteratee, accumulator, initFromCollection, eachFunc) { + function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { eachFunc(collection, function(value, index, collection) { - accumulator = initFromCollection - ? (initFromCollection = false, value) + accumulator = initAccum + ? (initAccum = false, value) : iteratee(accumulator, value, index, collection); }); return accumulator; diff --git a/internal/cloneSymbol.js b/internal/cloneSymbol.js index 56c9c932c..f0e1fd66d 100644 --- a/internal/cloneSymbol.js +++ b/internal/cloneSymbol.js @@ -1,11 +1,11 @@ -define(['./_Symbol'], function(_Symbol) { +define(['./Symbol'], function(Symbol) { /** Used as a safe reference for `undefined` in pre-ES5 environments. */ var undefined; /** Used to convert symbols to primitives and strings. */ - var symbolProto = _Symbol ? _Symbol.prototype : undefined, - symbolValueOf = _Symbol ? symbolProto.valueOf : undefined; + var symbolProto = Symbol ? Symbol.prototype : undefined, + symbolValueOf = Symbol ? symbolProto.valueOf : undefined; /** * Creates a clone of the `symbol` object. @@ -15,7 +15,7 @@ define(['./_Symbol'], function(_Symbol) { * @returns {Object} Returns the cloned symbol object. */ function cloneSymbol(symbol) { - return _Symbol ? Object(symbolValueOf.call(symbol)) : {}; + return Symbol ? Object(symbolValueOf.call(symbol)) : {}; } return cloneSymbol; diff --git a/internal/createAssigner.js b/internal/createAssigner.js index 917a59598..49521ee7e 100644 --- a/internal/createAssigner.js +++ b/internal/createAssigner.js @@ -26,7 +26,7 @@ define(['./isIterateeCall', '../rest'], function(isIterateeCall, rest) { while (++index < length) { var source = sources[index]; if (source) { - assigner(object, source, customizer); + assigner(object, source, index, customizer); } } return object; diff --git a/internal/createCaseFirst.js b/internal/createCaseFirst.js index 77ce4e616..c13c50d55 100644 --- a/internal/createCaseFirst.js +++ b/internal/createCaseFirst.js @@ -5,14 +5,15 @@ define(['./stringToArray', '../toString'], function(stringToArray, toString) { /** Used to compose unicode character classes. */ var rsAstralRange = '\\ud800-\\udfff', - rsComboRange = '\\u0300-\\u036f\\ufe20-\\ufe23', + rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23', + rsComboSymbolsRange = '\\u20d0-\\u20f0', rsVarRange = '\\ufe0e\\ufe0f'; /** Used to compose unicode capture groups. */ var rsZWJ = '\\u200d'; /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ - var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); + var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']'); /** * Creates a function like `_.lowerFirst`. diff --git a/internal/createPadding.js b/internal/createPadding.js index 9e4764ba1..d9b7a0f92 100644 --- a/internal/createPadding.js +++ b/internal/createPadding.js @@ -5,14 +5,15 @@ define(['../repeat', './stringSize', './stringToArray', '../toInteger'], functio /** Used to compose unicode character classes. */ var rsAstralRange = '\\ud800-\\udfff', - rsComboRange = '\\u0300-\\u036f\\ufe20-\\ufe23', + rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23', + rsComboSymbolsRange = '\\u20d0-\\u20f0', rsVarRange = '\\ufe0e\\ufe0f'; /** Used to compose unicode capture groups. */ var rsZWJ = '\\u200d'; /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ - var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); + var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']'); /* Built-in method references for those with the same name as other `lodash` methods. */ var nativeCeil = Math.ceil; diff --git a/internal/equalByTag.js b/internal/equalByTag.js index 0659481d1..b0c74ab4c 100644 --- a/internal/equalByTag.js +++ b/internal/equalByTag.js @@ -1,4 +1,4 @@ -define(['./Uint8Array', './_Symbol', './mapToArray', './setToArray'], function(Uint8Array, _Symbol, mapToArray, setToArray) { +define(['./Symbol', './Uint8Array', './mapToArray', './setToArray'], function(Symbol, Uint8Array, mapToArray, setToArray) { /** Used as a safe reference for `undefined` in pre-ES5 environments. */ var undefined; @@ -21,8 +21,8 @@ define(['./Uint8Array', './_Symbol', './mapToArray', './setToArray'], function(U var arrayBufferTag = '[object ArrayBuffer]'; /** Used to convert symbols to primitives and strings. */ - var symbolProto = _Symbol ? _Symbol.prototype : undefined, - symbolValueOf = _Symbol ? symbolProto.valueOf : undefined; + var symbolProto = Symbol ? Symbol.prototype : undefined, + symbolValueOf = Symbol ? symbolProto.valueOf : undefined; /** * A specialized version of `baseIsEqualDeep` for comparing objects of @@ -80,7 +80,7 @@ define(['./Uint8Array', './_Symbol', './mapToArray', './setToArray'], function(U equalFunc(convert(object), convert(other), customizer, bitmask | UNORDERED_COMPARE_FLAG); case symbolTag: - return !!_Symbol && (symbolValueOf.call(object) == symbolValueOf.call(other)); + return !!Symbol && (symbolValueOf.call(object) == symbolValueOf.call(other)); } return false; } diff --git a/internal/equalObjects.js b/internal/equalObjects.js index 7046b7098..f21af5ff4 100644 --- a/internal/equalObjects.js +++ b/internal/equalObjects.js @@ -4,8 +4,7 @@ define(['./baseHas', '../keys'], function(baseHas, keys) { var undefined; /** Used to compose bitmasks for comparison styles. */ - var UNORDERED_COMPARE_FLAG = 1, - PARTIAL_COMPARE_FLAG = 2; + var PARTIAL_COMPARE_FLAG = 2; /** * A specialized version of `baseIsEqualDeep` for objects with support for @@ -22,7 +21,6 @@ define(['./baseHas', '../keys'], function(baseHas, keys) { */ function equalObjects(object, other, equalFunc, customizer, bitmask, stack) { var isPartial = bitmask & PARTIAL_COMPARE_FLAG, - isUnordered = bitmask & UNORDERED_COMPARE_FLAG, objProps = keys(object), objLength = objProps.length, othProps = keys(other), @@ -34,8 +32,7 @@ define(['./baseHas', '../keys'], function(baseHas, keys) { var index = objLength; while (index--) { var key = objProps[index]; - if (!(isPartial ? key in other : baseHas(other, key)) || - !(isUnordered || key == othProps[index])) { + if (!(isPartial ? key in other : baseHas(other, key))) { return false; } } diff --git a/internal/getFuncName.js b/internal/getFuncName.js index 9f85eddea..891ea727e 100644 --- a/internal/getFuncName.js +++ b/internal/getFuncName.js @@ -1,5 +1,11 @@ define(['./realNames'], function(realNames) { + /** Used for built-in method references. */ + var objectProto = Object.prototype; + + /** Used to check objects for own properties. */ + var hasOwnProperty = objectProto.hasOwnProperty; + /** * Gets the name of `func`. * @@ -10,7 +16,7 @@ define(['./realNames'], function(realNames) { function getFuncName(func) { var result = (func.name + ''), array = realNames[result], - length = array ? array.length : 0; + length = hasOwnProperty.call(realNames, result) ? array.length : 0; while (length--) { var data = array[length], diff --git a/internal/mergeDefaults.js b/internal/mergeDefaults.js index c63b6d0ab..0519f03f4 100644 --- a/internal/mergeDefaults.js +++ b/internal/mergeDefaults.js @@ -1,4 +1,4 @@ -define(['./baseClone', './baseMerge', '../isObject'], function(baseClone, baseMerge, isObject) { +define(['./baseMerge', '../isObject'], function(baseMerge, isObject) { /** Used as a safe reference for `undefined` in pre-ES5 environments. */ var undefined; @@ -18,9 +18,9 @@ define(['./baseClone', './baseMerge', '../isObject'], function(baseClone, baseMe function mergeDefaults(objValue, srcValue, key, object, source, stack) { if (isObject(objValue) && isObject(srcValue)) { stack.set(srcValue, objValue); - baseMerge(objValue, srcValue, mergeDefaults, stack); + baseMerge(objValue, srcValue, undefined, mergeDefaults, stack); } - return objValue === undefined ? baseClone(srcValue) : objValue; + return objValue; } return mergeDefaults; diff --git a/internal/stringSize.js b/internal/stringSize.js index 8550a82eb..a5afdcbe6 100644 --- a/internal/stringSize.js +++ b/internal/stringSize.js @@ -2,13 +2,15 @@ define([], function() { /** Used to compose unicode character classes. */ var rsAstralRange = '\\ud800-\\udfff', - rsComboRange = '\\u0300-\\u036f\\ufe20-\\ufe23', + rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23', + rsComboSymbolsRange = '\\u20d0-\\u20f0', rsVarRange = '\\ufe0e\\ufe0f'; /** Used to compose unicode capture groups. */ var rsAstral = '[' + rsAstralRange + ']', - rsCombo = '[' + rsComboRange + ']', - rsModifier = '(?:\\ud83c[\\udffb-\\udfff])', + rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']', + rsFitz = '\\ud83c[\\udffb-\\udfff]', + rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', rsNonAstral = '[^' + rsAstralRange + ']', rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', @@ -22,14 +24,15 @@ define([], function() { rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ - var reComplexSymbol = RegExp(rsSymbol + rsSeq, 'g'); + var reComplexSymbol = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ - var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); + var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']'); /** * Gets the number of symbols in `string`. * + * @private * @param {string} string The string to inspect. * @returns {number} Returns the string size. */ diff --git a/internal/stringToArray.js b/internal/stringToArray.js index a34afbf30..3c26d917a 100644 --- a/internal/stringToArray.js +++ b/internal/stringToArray.js @@ -2,13 +2,15 @@ define([], function() { /** Used to compose unicode character classes. */ var rsAstralRange = '\\ud800-\\udfff', - rsComboRange = '\\u0300-\\u036f\\ufe20-\\ufe23', + rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23', + rsComboSymbolsRange = '\\u20d0-\\u20f0', rsVarRange = '\\ufe0e\\ufe0f'; /** Used to compose unicode capture groups. */ var rsAstral = '[' + rsAstralRange + ']', - rsCombo = '[' + rsComboRange + ']', - rsModifier = '(?:\\ud83c[\\udffb-\\udfff])', + rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']', + rsFitz = '\\ud83c[\\udffb-\\udfff]', + rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', rsNonAstral = '[^' + rsAstralRange + ']', rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', @@ -22,7 +24,7 @@ define([], function() { rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ - var reComplexSymbol = RegExp(rsSymbol + rsSeq, 'g'); + var reComplexSymbol = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); /** * Converts `string` to an array. diff --git a/intersection.js b/intersection.js index 15dec2ebf..c7bcd1993 100644 --- a/intersection.js +++ b/intersection.js @@ -11,6 +11,7 @@ define(['./internal/arrayMap', './internal/baseIntersection', './rest', './inter * @param {...Array} [arrays] The arrays to inspect. * @returns {Array} Returns the new array of shared values. * @example + * * _.intersection([2, 1], [4, 2], [1, 2]); * // => [2] */ diff --git a/isEqualWith.js b/isEqualWith.js index ae371140f..3cc3724af 100644 --- a/isEqualWith.js +++ b/isEqualWith.js @@ -6,7 +6,7 @@ define(['./internal/baseIsEqual'], function(baseIsEqual) { /** * This method is like `_.isEqual` except that it accepts `customizer` which is * invoked to compare values. If `customizer` returns `undefined` comparisons are - * handled by the method instead. The `customizer` is invoked with up to seven arguments: + * handled by the method instead. The `customizer` is invoked with up to six arguments: * (objValue, othValue [, index|key, object, other, stack]). * * @static diff --git a/isMatchWith.js b/isMatchWith.js index 6b11b913c..f42d09106 100644 --- a/isMatchWith.js +++ b/isMatchWith.js @@ -6,7 +6,7 @@ define(['./internal/baseIsMatch', './internal/getMatchData'], function(baseIsMat /** * This method is like `_.isMatch` except that it accepts `customizer` which * is invoked to compare values. If `customizer` returns `undefined` comparisons - * are handled by the method instead. The `customizer` is invoked with three + * are handled by the method instead. The `customizer` is invoked with five * arguments: (objValue, srcValue, index|key, object, source). * * @static diff --git a/keyBy.js b/keyBy.js index 65ee419b5..2c08c54ae 100644 --- a/keyBy.js +++ b/keyBy.js @@ -10,7 +10,7 @@ define(['./internal/createAggregator'], function(createAggregator) { * @memberOf _ * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Function|Object|string} [iteratee=_.identity] The iteratee to transform keys. * @returns {Object} Returns the composed aggregate object. * @example * @@ -19,13 +19,13 @@ define(['./internal/createAggregator'], function(createAggregator) { * { 'dir': 'right', 'code': 100 } * ]; * - * _.keyBy(keyData, 'dir'); - * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } - * * _.keyBy(keyData, function(o) { * return String.fromCharCode(o.code); * }); * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } + * + * _.keyBy(keyData, 'dir'); + * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } */ var keyBy = createAggregator(function(result, value, key) { result[key] = value; diff --git a/main.js b/main.js index 7224e37dc..ab0861a85 100644 --- a/main.js +++ b/main.js @@ -1,6 +1,6 @@ /** * @license - * lodash 4.0.0 (Custom Build) + * lodash 4.0.1 (Custom Build) * Build: `lodash exports="amd" -d -o ./main.js` * Copyright 2012-2016 The Dojo Foundation * Based on Underscore.js 1.8.3 @@ -13,7 +13,7 @@ var undefined; /** Used as the semantic version number. */ - var VERSION = '4.0.0'; + var VERSION = '4.0.1'; /** Used to compose bitmasks for wrapper metadata. */ var BIND_FLAG = 1, @@ -163,7 +163,8 @@ /** Used to compose unicode character classes. */ var rsAstralRange = '\\ud800-\\udfff', - rsComboRange = '\\u0300-\\u036f\\ufe20-\\ufe23', + rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23', + rsComboSymbolsRange = '\\u20d0-\\u20f0', rsDingbatRange = '\\u2700-\\u27bf', rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', @@ -177,12 +178,13 @@ /** Used to compose unicode capture groups. */ var rsAstral = '[' + rsAstralRange + ']', rsBreak = '[' + rsBreakRange + ']', - rsCombo = '[' + rsComboRange + ']', + rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']', rsDigits = '\\d+', rsDingbat = '[' + rsDingbatRange + ']', rsLower = '[' + rsLowerRange + ']', rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', - rsModifier = '(?:\\ud83c[\\udffb-\\udfff])', + rsFitz = '\\ud83c[\\udffb-\\udfff]', + rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', rsNonAstral = '[^' + rsAstralRange + ']', rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', @@ -199,14 +201,17 @@ rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq, rsSymbol = '(?:' + [rsNonAstral + rsCombo + '?', rsCombo, rsRegional, rsSurrPair, rsAstral].join('|') + ')'; - /** Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks). */ + /** + * Used to match [combining diacritical marks](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks) and + * [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/Combining_Diacritical_Marks_for_Symbols). + */ var reComboMark = RegExp(rsCombo, 'g'); /** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */ - var reComplexSymbol = RegExp(rsSymbol + rsSeq, 'g'); + var reComplexSymbol = RegExp(rsFitz + '(?=' + rsFitz + ')|' + rsSymbol + rsSeq, 'g'); /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ - var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); + var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']'); /** Used to match non-compound words composed of alphanumeric characters. */ var reBasicWord = /[a-zA-Z0-9]+/g; @@ -216,7 +221,8 @@ rsUpper + '?' + rsLower + '+(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', rsUpperMisc + '+(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')', rsUpper + '?' + rsLowerMisc + '+', - rsDigits + '(?:' + rsLowerMisc + '+)?', + rsUpper + '+', + rsDigits, rsEmoji ].join('|'), 'g'); @@ -594,14 +600,14 @@ * @param {Array} array The array to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {*} [accumulator] The initial value. - * @param {boolean} [initFromArray] Specify using the first element of `array` as the initial value. + * @param {boolean} [initAccum] Specify using the first element of `array` as the initial value. * @returns {*} Returns the accumulated value. */ - function arrayReduce(array, iteratee, accumulator, initFromArray) { + function arrayReduce(array, iteratee, accumulator, initAccum) { var index = -1, length = array.length; - if (initFromArray && length) { + if (initAccum && length) { accumulator = array[++index]; } while (++index < length) { @@ -618,12 +624,12 @@ * @param {Array} array The array to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {*} [accumulator] The initial value. - * @param {boolean} [initFromArray] Specify using the last element of `array` as the initial value. + * @param {boolean} [initAccum] Specify using the last element of `array` as the initial value. * @returns {*} Returns the accumulated value. */ - function arrayReduceRight(array, iteratee, accumulator, initFromArray) { + function arrayReduceRight(array, iteratee, accumulator, initAccum) { var length = array.length; - if (initFromArray && length) { + if (initAccum && length) { accumulator = array[--length]; } while (length--) { @@ -685,7 +691,7 @@ /** * The base implementation of methods like `_.find` and `_.findKey`, without * support for iteratee shorthands, which iterates over `collection` using - * the provided `eachFunc`. + * `eachFunc`. * * @private * @param {Array|Object} collection The collection to search. @@ -753,21 +759,20 @@ /** * The base implementation of `_.reduce` and `_.reduceRight`, without support - * for iteratee shorthands, which iterates over `collection` using the provided - * `eachFunc`. + * for iteratee shorthands, which iterates over `collection` using `eachFunc`. * * @private * @param {Array|Object} collection The collection to iterate over. * @param {Function} iteratee The function invoked per iteration. * @param {*} accumulator The initial value. - * @param {boolean} initFromCollection Specify using the first or last element of `collection` as the initial value. + * @param {boolean} initAccum Specify using the first or last element of `collection` as the initial value. * @param {Function} eachFunc The function to iterate over `collection`. * @returns {*} Returns the accumulated value. */ - function baseReduce(collection, iteratee, accumulator, initFromCollection, eachFunc) { + function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) { eachFunc(collection, function(value, index, collection) { - accumulator = initFromCollection - ? (initFromCollection = false, value) + accumulator = initAccum + ? (initAccum = false, value) : iteratee(accumulator, value, index, collection); }); return accumulator; @@ -1161,6 +1166,7 @@ /** * Gets the number of symbols in `string`. * + * @private * @param {string} string The string to inspect. * @returns {number} Returns the string size. */ @@ -1276,14 +1282,14 @@ ); /** Built-in value references. */ - var _Symbol = context.Symbol, - Reflect = context.Reflect, + var Reflect = context.Reflect, + Symbol = context.Symbol, Uint8Array = context.Uint8Array, clearTimeout = context.clearTimeout, enumerate = Reflect ? Reflect.enumerate : undefined, getPrototypeOf = Object.getPrototypeOf, getOwnPropertySymbols = Object.getOwnPropertySymbols, - iteratorSymbol = typeof (iteratorSymbol = _Symbol && _Symbol.iterator) == 'symbol' ? iteratorSymbol : undefined, + iteratorSymbol = typeof (iteratorSymbol = Symbol && Symbol.iterator) == 'symbol' ? iteratorSymbol : undefined, propertyIsEnumerable = objectProto.propertyIsEnumerable, setTimeout = context.setTimeout, splice = arrayProto.splice; @@ -1314,9 +1320,9 @@ setCtorString = Set ? funcToString.call(Set) : ''; /** Used to convert symbols to primitives and strings. */ - var symbolProto = _Symbol ? _Symbol.prototype : undefined, - symbolValueOf = _Symbol ? symbolProto.valueOf : undefined, - symbolToString = _Symbol ? symbolProto.toString : undefined; + var symbolProto = Symbol ? Symbol.prototype : undefined, + symbolValueOf = Symbol ? symbolProto.valueOf : undefined, + symbolToString = Symbol ? symbolProto.toString : undefined; /** Used to lookup unminified function names. */ var realNames = {}; @@ -1364,13 +1370,12 @@ * The chainable wrapper methods are: * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, * `at`, `before`, `bind`, `bindAll`, `bindKey`, `chain`, `chunk`, `commit`, - * `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, `curry`, + * `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, `curry`, * `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, `difference`, - * `differenceBy`, `differenceWith`, `drop`, `dropRight`, `dropRightWhile`, + * `differenceBy`, `differenceWith`, `drop`, `dropRight`, `dropRightWhile`, * `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flip`, `flow`, - * `flowRight`, `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, - * `forOwnRight`, `fromPairs`, `functions`, `functionsIn`, `groupBy`, `initial`, - * `intersection`, `intersectionBy`, `intersectionWith`, invert`, `invokeMap`, + * `flowRight`, `fromPairs`, `functions`, `functionsIn`, `groupBy`, `initial`, + * `intersection`, `intersectionBy`, `intersectionWith`, `invert`, `invokeMap`, * `iteratee`, `keyBy`, `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, * `matches`, `matchesProperty`, `memoize`, `merge`, `mergeWith`, `method`, * `methodOf`, `mixin`, `negate`, `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, @@ -1389,22 +1394,23 @@ * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `endsWith`, `eq`, * `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, - * `findLast`, `findLastIndex`, `findLastKey`, `floor`, `get`, `gt`, `gte`, - * `has`, `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, - * `invoke`, `isArguments`, `isArray`, `isArrayLike`, `isArrayLikeObject`, - * `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, - * `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMatch`, - * `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, - * `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, `isSafeInteger`, - * `isString`, `isUndefined`, `isTypedArray`, `join`, `kebabCase`, `last`, - * `lastIndexOf`, `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, - * `mean`, `min`, `minBy`, `noConflict`, `noop`, `now`, `pad`, `padEnd`, - * `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, `repeat`, - * `result`, `round`, `runInContext`, `sample`, `shift`, `size`, `snakeCase`, - * `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`, - * `startCase`, `startsWith`, `subtract`, `sum`, sumBy`, `template`, `times`, - * `toLower`, `toInteger`, `toLength`, `toNumber`, `toSafeInteger`, toString`, - * `toUpper`, `trim`, `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, + * `findLast`, `findLastIndex`, `findLastKey`, `floor`, `forEach`, `forEachRight`, + * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, + * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, + * `isArguments`, `isArray`, `isArrayLike`, `isArrayLikeObject`, `isBoolean`, + * `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, `isError`, + * `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMatch`, `isMatchWith`, + * `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, `isObject`, `isObjectLike`, + * `isPlainObject`, `isRegExp`, `isSafeInteger`, `isString`, `isUndefined`, + * `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `lowerCase`, + * `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `min`, `minBy`, + * `noConflict`, `noop`, `now`, `pad`, `padEnd`, `padStart`, `parseInt`, + * `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, `round`, + * `runInContext`, `sample`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, + * `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`, `startCase`, + * `startsWith`, `subtract`, `sum`, `sumBy`, `template`, `times`, `toLower`, + * `toInteger`, `toLength`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, + * `trim`, `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, * `upperCase`, `upperFirst`, `value`, and `words` * * @name _ @@ -2664,7 +2670,6 @@ * The base implementation of `_.invoke` without support for individual * method arguments. * - * * @private * @param {Object} object The object to query. * @param {Array|string} path The path of the method to invoke. @@ -2807,7 +2812,10 @@ var stack = new Stack, result = customizer ? customizer(objValue, srcValue, key, object, source, stack) : undefined; - if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack) : result)) { + if (!(result === undefined + ? baseIsEqual(srcValue, objValue, customizer, UNORDERED_COMPARE_FLAG | PARTIAL_COMPARE_FLAG, stack) + : result + )) { return false; } } @@ -2943,10 +2951,11 @@ * @private * @param {Object} object The destination object. * @param {Object} source The source object. + * @param {number} srcIndex The index of `source`. * @param {Function} [customizer] The function to customize merged values. * @param {Object} [stack] Tracks traversed source values and their merged counterparts. */ - function baseMerge(object, source, customizer, stack) { + function baseMerge(object, source, srcIndex, customizer, stack) { if (object === source) { return; } @@ -2958,7 +2967,7 @@ } if (isObject(srcValue)) { stack || (stack = new Stack); - baseMergeDeep(object, source, key, baseMerge, customizer, stack); + baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); } else { var newValue = customizer ? customizer(object[key], srcValue, (key + ''), object, source, stack) : undefined; @@ -2979,11 +2988,12 @@ * @param {Object} object The destination object. * @param {Object} source The source object. * @param {string} key The key of the value to merge. + * @param {number} srcIndex The index of `source`. * @param {Function} mergeFunc The function to merge values. * @param {Function} [customizer] The function to customize assigned values. * @param {Object} [stack] Tracks traversed source values and their merged counterparts. */ - function baseMergeDeep(object, source, key, mergeFunc, customizer, stack) { + function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { var objValue = object[key], srcValue = source[key], stacked = stack.get(srcValue) || stack.get(objValue); @@ -2998,24 +3008,36 @@ if (isCommon) { newValue = srcValue; if (isArray(srcValue) || isTypedArray(srcValue)) { - newValue = isArray(objValue) - ? objValue - : ((isArrayLikeObject(objValue)) ? copyArray(objValue) : baseClone(srcValue)); + if (isArray(objValue)) { + newValue = srcIndex ? copyArray(objValue) : objValue; + } + else if (isArrayLikeObject(objValue)) { + newValue = copyArray(objValue); + } + else { + newValue = baseClone(srcValue); + } } else if (isPlainObject(srcValue) || isArguments(srcValue)) { - newValue = isArguments(objValue) - ? toPlainObject(objValue) - : (isObject(objValue) ? objValue : baseClone(srcValue)); + if (isArguments(objValue)) { + newValue = toPlainObject(objValue); + } + else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) { + newValue = baseClone(srcValue); + } + else { + newValue = srcIndex ? baseClone(objValue) : objValue; + } } else { - isCommon = isFunction(srcValue); + isCommon = false; } } stack.set(srcValue, newValue); if (isCommon) { // Recursively merge objects and arrays (susceptible to call stack limits). - mergeFunc(newValue, srcValue, customizer, stack); + mergeFunc(newValue, srcValue, srcIndex, customizer, stack); } assignMergeValue(object, key, newValue); } @@ -3079,7 +3101,7 @@ function basePickBy(object, predicate) { var result = {}; baseForIn(object, function(value, key) { - if (predicate(value)) { + if (predicate(value, key)) { result[key] = value; } }); @@ -3664,7 +3686,7 @@ * @returns {Object} Returns the cloned symbol object. */ function cloneSymbol(symbol) { - return _Symbol ? Object(symbolValueOf.call(symbol)) : {}; + return Symbol ? Object(symbolValueOf.call(symbol)) : {}; } /** @@ -3867,7 +3889,7 @@ while (++index < length) { var source = sources[index]; if (source) { - assigner(object, source, customizer); + assigner(object, source, index, customizer); } } return object; @@ -4552,7 +4574,7 @@ equalFunc(convert(object), convert(other), customizer, bitmask | UNORDERED_COMPARE_FLAG); case symbolTag: - return !!_Symbol && (symbolValueOf.call(object) == symbolValueOf.call(other)); + return !!Symbol && (symbolValueOf.call(object) == symbolValueOf.call(other)); } return false; } @@ -4572,7 +4594,6 @@ */ function equalObjects(object, other, equalFunc, customizer, bitmask, stack) { var isPartial = bitmask & PARTIAL_COMPARE_FLAG, - isUnordered = bitmask & UNORDERED_COMPARE_FLAG, objProps = keys(object), objLength = objProps.length, othProps = keys(other), @@ -4584,8 +4605,7 @@ var index = objLength; while (index--) { var key = objProps[index]; - if (!(isPartial ? key in other : baseHas(other, key)) || - !(isUnordered || key == othProps[index])) { + if (!(isPartial ? key in other : baseHas(other, key))) { return false; } } @@ -4655,7 +4675,7 @@ function getFuncName(func) { var result = (func.name + ''), array = realNames[result], - length = array ? array.length : 0; + length = hasOwnProperty.call(realNames, result) ? array.length : 0; while (length--) { var data = array[length], @@ -5096,9 +5116,9 @@ function mergeDefaults(objValue, srcValue, key, object, source, stack) { if (isObject(objValue) && isObject(srcValue)) { stack.set(srcValue, objValue); - baseMerge(objValue, srcValue, mergeDefaults, stack); + baseMerge(objValue, srcValue, undefined, mergeDefaults, stack); } - return objValue === undefined ? baseClone(srcValue) : objValue; + return objValue; } /** @@ -5312,8 +5332,11 @@ * // => [1] */ var concat = rest(function(array, values) { + if (!isArray(array)) { + array = array == null ? [] : [Object(array)]; + } values = baseFlatten(values); - return arrayConcat(isArray(array) ? array : [Object(array)], values); + return arrayConcat(array, values); }); /** @@ -5745,7 +5768,7 @@ while (++index < length) { var pair = pairs[index]; - baseSet(result, pair[0], pair[1]); + result[pair[0]] = pair[1]; } return result; } @@ -5834,6 +5857,7 @@ * @param {...Array} [arrays] The arrays to inspect. * @returns {Array} Returns the new array of shared values. * @example + * * _.intersection([2, 1], [4, 2], [1, 2]); * // => [2] */ @@ -6026,7 +6050,7 @@ * * var array = [1, 2, 3, 1, 2, 3]; * - * _.pull(array, [2, 3]); + * _.pullAll(array, [2, 3]); * console.log(array); * // => [1, 1] */ @@ -6150,6 +6174,7 @@ * **Note:** This method mutates `array` and is based on * [`Array#reverse`](https://mdn.io/Array/reverse). * + * @static * @memberOf _ * @category Array * @returns {Array} Returns `array`. @@ -7108,7 +7133,7 @@ /** * This method is the wrapper version of `_.flatMap`. * - * @static + * @name flatMap * @memberOf _ * @category Seq * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration. @@ -7259,7 +7284,7 @@ * * @name value * @memberOf _ - * @alias run, toJSON, valueOf + * @alias toJSON, valueOf * @category Seq * @returns {*} Returns the resolved unwrapped value. * @example @@ -7283,7 +7308,7 @@ * @memberOf _ * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Function|Object|string} [iteratee=_.identity] The iteratee to transform keys. * @returns {Object} Returns the composed aggregate object. * @example * @@ -7507,14 +7532,14 @@ /** * Creates an object composed of keys generated from the results of running * each element of `collection` through `iteratee`. The corresponding value - * of each key is an array of the elements responsible for generating the key. + * of each key is an array of elements responsible for generating the key. * The iteratee is invoked with one argument: (value). * * @static * @memberOf _ * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Function|Object|string} [iteratee=_.identity] The iteratee to transform keys. * @returns {Object} Returns the composed aggregate object. * @example * @@ -7619,7 +7644,7 @@ * @memberOf _ * @category Collection * @param {Array|Object} collection The collection to iterate over. - * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. + * @param {Function|Object|string} [iteratee=_.identity] The iteratee to transform keys. * @returns {Object} Returns the composed aggregate object. * @example * @@ -7628,13 +7653,13 @@ * { 'dir': 'right', 'code': 100 } * ]; * - * _.keyBy(keyData, 'dir'); - * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } - * * _.keyBy(keyData, function(o) { * return String.fromCharCode(o.code); * }); * // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } } + * + * _.keyBy(keyData, 'dir'); + * // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } } */ var keyBy = createAggregator(function(result, value, key) { result[key] = value; @@ -7666,11 +7691,11 @@ * return n * n; * } * - * _.map([1, 2], square); - * // => [3, 6] + * _.map([4, 8], square); + * // => [16, 64] * - * _.map({ 'a': 1, 'b': 2 }, square); - * // => [3, 6] (iteration order is not guaranteed) + * _.map({ 'a': 4, 'b': 8 }, square); + * // => [16, 64] (iteration order is not guaranteed) * * var users = [ * { 'user': 'barney' }, @@ -7729,9 +7754,9 @@ /** * Creates an array of elements split into two groups, the first of which - * contains elements `predicate` returns truthy for, while the second of which - * contains elements `predicate` returns falsey for. The predicate is invoked - * with three arguments: (value, index|key, collection). + * contains elements `predicate` returns truthy for, the second of which + * contains elements `predicate` returns falsey for. The predicate is + * invoked with one argument: (value). * * @static * @memberOf _ @@ -7803,9 +7828,9 @@ */ function reduce(collection, iteratee, accumulator) { var func = isArray(collection) ? arrayReduce : baseReduce, - initFromCollection = arguments.length < 3; + initAccum = arguments.length < 3; - return func(collection, getIteratee(iteratee, 4), accumulator, initFromCollection, baseEach); + return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEach); } /** @@ -7830,9 +7855,9 @@ */ function reduceRight(collection, iteratee, accumulator) { var func = isArray(collection) ? arrayReduceRight : baseReduce, - initFromCollection = arguments.length < 3; + initAccum = arguments.length < 3; - return func(collection, getIteratee(iteratee, 4), accumulator, initFromCollection, baseEachRight); + return func(collection, getIteratee(iteratee, 4), accumulator, initAccum, baseEachRight); } /** @@ -7896,7 +7921,8 @@ } /** - * Gets `n` random elements from `collection`. + * Gets `n` random elements at unique keys from `collection` up to the + * size of `collection`. * * @static * @memberOf _ @@ -7906,8 +7932,11 @@ * @returns {Array} Returns the random elements. * @example * - * _.sampleSize([1, 2, 3, 4], 2); + * _.sampleSize([1, 2, 3], 2); * // => [3, 1] + * + * _.sampleSize([1, 2, 3], 4); + * // => [2, 3, 1] */ function sampleSize(collection, n) { var index = -1, @@ -9071,7 +9100,7 @@ * This method is like `_.clone` except that it accepts `customizer` which * is invoked to produce the cloned value. If `customizer` returns `undefined` * cloning is handled by the method instead. The `customizer` is invoked with - * up to five arguments; (value [, index|key, object, stack]). + * up to four arguments; (value [, index|key, object, stack]). * * @static * @memberOf _ @@ -9087,7 +9116,7 @@ * } * } * - * var el = _.clone(document.body, customizer); + * var el = _.cloneWith(document.body, customizer); * * console.log(el === document.body); * // => false @@ -9137,7 +9166,7 @@ * } * } * - * var el = _.cloneDeep(document.body, customizer); + * var el = _.cloneDeepWith(document.body, customizer); * * console.log(el === document.body); * // => false @@ -9465,7 +9494,7 @@ /** * This method is like `_.isEqual` except that it accepts `customizer` which is * invoked to compare values. If `customizer` returns `undefined` comparisons are - * handled by the method instead. The `customizer` is invoked with up to seven arguments: + * handled by the method instead. The `customizer` is invoked with up to six arguments: * (objValue, othValue [, index|key, object, other, stack]). * * @static @@ -9715,7 +9744,7 @@ /** * This method is like `_.isMatch` except that it accepts `customizer` which * is invoked to compare values. If `customizer` returns `undefined` comparisons - * are handled by the method instead. The `customizer` is invoked with three + * are handled by the method instead. The `customizer` is invoked with five * arguments: (objValue, srcValue, index|key, object, source). * * @static @@ -10186,7 +10215,7 @@ * @memberOf _ * @category Lang * @param {*} value The value to convert. - * @return {number} Returns the converted integer. + * @returns {number} Returns the converted integer. * @example * * _.toLength(3); @@ -10325,7 +10354,7 @@ return ''; } if (isSymbol(value)) { - return _Symbol ? symbolToString.call(value) : ''; + return Symbol ? symbolToString.call(value) : ''; } var result = (value + ''); return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; @@ -10427,7 +10456,7 @@ * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); * // => { 'a': 1, 'b': 2 } */ - var assignInWith = createAssigner(function(object, source, customizer) { + var assignInWith = createAssigner(function(object, source, srcIndex, customizer) { copyObjectWith(source, keysIn(source), object, customizer); }); @@ -10457,7 +10486,7 @@ * defaults({ 'a': 1 }, { 'b': 2 }, { 'a': 3 }); * // => { 'a': 1, 'b': 2 } */ - var assignWith = createAssigner(function(object, source, customizer) { + var assignWith = createAssigner(function(object, source, srcIndex, customizer) { copyObjectWith(source, keys(source), object, customizer); }); @@ -11137,8 +11166,8 @@ * _.merge(users, ages); * // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] } */ - var merge = createAssigner(function(object, source) { - baseMerge(object, source); + var merge = createAssigner(function(object, source, srcIndex) { + baseMerge(object, source, srcIndex); }); /** @@ -11176,8 +11205,8 @@ * _.mergeWith(object, other, customizer); * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] } */ - var mergeWith = createAssigner(function(object, source, customizer) { - baseMerge(object, source, customizer); + var mergeWith = createAssigner(function(object, source, srcIndex, customizer) { + baseMerge(object, source, srcIndex, customizer); }); /** @@ -11225,9 +11254,9 @@ * // => { 'b': '2' } */ function omitBy(object, predicate) { - predicate = getIteratee(predicate); - return basePickBy(object, function(value) { - return !predicate(value); + predicate = getIteratee(predicate, 2); + return basePickBy(object, function(value, key) { + return !predicate(value, key); }); } @@ -11270,7 +11299,7 @@ * // => { 'a': 1, 'c': 3 } */ function pickBy(object, predicate) { - return object == null ? {} : basePickBy(object, getIteratee(predicate)); + return object == null ? {} : basePickBy(object, getIteratee(predicate, 2)); } /** @@ -12037,7 +12066,7 @@ * `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/#E) + * **Note:** This method aligns with the [ES5 implementation](https://es5.github.io/#x15.1.2.2) * of `parseInt`. * * @static @@ -12829,7 +12858,7 @@ * [_.matches({ 'a': 1 }), _.constant('matches A')], * [_.conforms({ 'b': _.isNumber }), _.constant('matches B')], * [_.constant(true), _.constant('no match')] - * ]) + * ]); * * func({ 'a': 1, 'b': 2 }); * // => 'matches A' @@ -13200,7 +13229,9 @@ * var lodash = _.noConflict(); */ function noConflict() { - root._ = oldDash; + if (root._ === this) { + root._ = oldDash; + } return this; } @@ -13365,8 +13396,7 @@ * Creates an array of numbers (positive and/or negative) progressing from * `start` up to, but not including, `end`. A step of `-1` is used if a negative * `start` is specified without an `end` or `step`. If `end` is not specified - * it's set to `start` with `start` then set to `0`. If `end` is less than - * `start` a zero-length range is created unless a negative `step` is specified. + * it's set to `start` with `start` then set to `0`. * * **Note:** JavaScript follows the IEEE-754 standard for resolving * floating-point values which can produce unexpected results. @@ -13634,7 +13664,7 @@ * * var objects = [{ 'n': 1 }, { 'n': 2 }]; * - * _.maxBy(objects, function(o) { return o.a; }); + * _.maxBy(objects, function(o) { return o.n; }); * // => { 'n': 2 } * * // using the `_.property` iteratee shorthand @@ -13702,7 +13732,7 @@ * * var objects = [{ 'n': 1 }, { 'n': 2 }]; * - * _.minBy(objects, function(o) { return o.a; }); + * _.minBy(objects, function(o) { return o.n; }); * // => { 'n': 1 } * * // using the `_.property` iteratee shorthand @@ -13986,8 +14016,6 @@ lodash.zipWith = zipWith; // Add aliases. - lodash.each = forEach; - lodash.eachRight = forEachRight; lodash.extend = assignIn; lodash.extendWith = assignInWith; @@ -14130,6 +14158,8 @@ lodash.upperFirst = upperFirst; // Add aliases. + lodash.each = forEach; + lodash.eachRight = forEachRight; lodash.first = head; mixin(lodash, (function() { diff --git a/map.js b/map.js index 32c505cb2..494193f52 100644 --- a/map.js +++ b/map.js @@ -26,11 +26,11 @@ define(['./internal/arrayMap', './internal/baseIteratee', './internal/baseMap', * return n * n; * } * - * _.map([1, 2], square); - * // => [3, 6] + * _.map([4, 8], square); + * // => [16, 64] * - * _.map({ 'a': 1, 'b': 2 }, square); - * // => [3, 6] (iteration order is not guaranteed) + * _.map({ 'a': 4, 'b': 8 }, square); + * // => [16, 64] (iteration order is not guaranteed) * * var users = [ * { 'user': 'barney' }, diff --git a/maxBy.js b/maxBy.js index cff461a4f..1f2d4b113 100644 --- a/maxBy.js +++ b/maxBy.js @@ -18,7 +18,7 @@ define(['./internal/baseExtremum', './internal/baseIteratee', './gt'], function( * * var objects = [{ 'n': 1 }, { 'n': 2 }]; * - * _.maxBy(objects, function(o) { return o.a; }); + * _.maxBy(objects, function(o) { return o.n; }); * // => { 'n': 2 } * * // using the `_.property` iteratee shorthand diff --git a/merge.js b/merge.js index 80bc6f49c..35b02d762 100644 --- a/merge.js +++ b/merge.js @@ -29,8 +29,8 @@ define(['./internal/baseMerge', './internal/createAssigner'], function(baseMerge * _.merge(users, ages); * // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] } */ - var merge = createAssigner(function(object, source) { - baseMerge(object, source); + var merge = createAssigner(function(object, source, srcIndex) { + baseMerge(object, source, srcIndex); }); return merge; diff --git a/mergeWith.js b/mergeWith.js index 2e1440cbc..792236a77 100644 --- a/mergeWith.js +++ b/mergeWith.js @@ -35,8 +35,8 @@ define(['./internal/baseMerge', './internal/createAssigner'], function(baseMerge * _.mergeWith(object, other, customizer); * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] } */ - var mergeWith = createAssigner(function(object, source, customizer) { - baseMerge(object, source, customizer); + var mergeWith = createAssigner(function(object, source, srcIndex, customizer) { + baseMerge(object, source, srcIndex, customizer); }); return mergeWith; diff --git a/minBy.js b/minBy.js index 6f124cade..11e0aed5f 100644 --- a/minBy.js +++ b/minBy.js @@ -18,7 +18,7 @@ define(['./internal/baseExtremum', './internal/baseIteratee', './lt'], function( * * var objects = [{ 'n': 1 }, { 'n': 2 }]; * - * _.minBy(objects, function(o) { return o.a; }); + * _.minBy(objects, function(o) { return o.n; }); * // => { 'n': 1 } * * // using the `_.property` iteratee shorthand diff --git a/object.js b/object.js index bef7274bc..18aeb1459 100644 --- a/object.js +++ b/object.js @@ -1,4 +1,4 @@ -define(['./assign', './assignIn', './assignInWith', './assignWith', './create', './defaults', './defaultsDeep', './findKey', './findLastKey', './forIn', './forInRight', './forOwn', './forOwnRight', './functions', './functionsIn', './get', './has', './hasIn', './invert', './invoke', './keys', './keysIn', './mapKeys', './mapValues', './merge', './mergeWith', './omit', './omitBy', './pick', './pickBy', './result', './set', './setWith', './toPairs', './toPairsIn', './transform', './unset', './values', './valuesIn'], function(assign, assignIn, assignInWith, assignWith, create, defaults, defaultsDeep, findKey, findLastKey, forIn, forInRight, forOwn, forOwnRight, functions, functionsIn, get, has, hasIn, invert, invoke, keys, keysIn, mapKeys, mapValues, merge, mergeWith, omit, omitBy, pick, pickBy, result, set, setWith, toPairs, toPairsIn, transform, unset, values, valuesIn) { +define(['./assign', './assignIn', './assignInWith', './assignWith', './create', './defaults', './defaultsDeep', './extend', './extendWith', './findKey', './findLastKey', './forIn', './forInRight', './forOwn', './forOwnRight', './functions', './functionsIn', './get', './has', './hasIn', './invert', './invoke', './keys', './keysIn', './mapKeys', './mapValues', './merge', './mergeWith', './omit', './omitBy', './pick', './pickBy', './result', './set', './setWith', './toPairs', './toPairsIn', './transform', './unset', './values', './valuesIn'], function(assign, assignIn, assignInWith, assignWith, create, defaults, defaultsDeep, extend, extendWith, findKey, findLastKey, forIn, forInRight, forOwn, forOwnRight, functions, functionsIn, get, has, hasIn, invert, invoke, keys, keysIn, mapKeys, mapValues, merge, mergeWith, omit, omitBy, pick, pickBy, result, set, setWith, toPairs, toPairsIn, transform, unset, values, valuesIn) { return { 'assign': assign, 'assignIn': assignIn, @@ -7,6 +7,8 @@ define(['./assign', './assignIn', './assignInWith', './assignWith', './create', 'create': create, 'defaults': defaults, 'defaultsDeep': defaultsDeep, + 'extend': extend, + 'extendWith': extendWith, 'findKey': findKey, 'findLastKey': findLastKey, 'forIn': forIn, diff --git a/omitBy.js b/omitBy.js index 268dbf3d5..2e5ca2f59 100644 --- a/omitBy.js +++ b/omitBy.js @@ -19,9 +19,9 @@ define(['./internal/baseIteratee', './internal/basePickBy'], function(baseIterat * // => { 'b': '2' } */ function omitBy(object, predicate) { - predicate = baseIteratee(predicate); - return basePickBy(object, function(value) { - return !predicate(value); + predicate = baseIteratee(predicate, 2); + return basePickBy(object, function(value, key) { + return !predicate(value, key); }); } diff --git a/package.json b/package.json index a4e5dc15a..ab391f4b5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lodash-amd", - "version": "4.0.0", + "version": "4.0.1", "description": "Lodash exported as AMD modules.", "homepage": "https://lodash.com/custom-builds", "license": "MIT", diff --git a/parseInt.js b/parseInt.js index b545bc192..7e6e129b2 100644 --- a/parseInt.js +++ b/parseInt.js @@ -14,7 +14,7 @@ define(['./internal/root', './toString'], function(root, toString) { * `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/#E) + * **Note:** This method aligns with the [ES5 implementation](https://es5.github.io/#x15.1.2.2) * of `parseInt`. * * @static diff --git a/partition.js b/partition.js index 72ba9bbf8..79cdacd05 100644 --- a/partition.js +++ b/partition.js @@ -2,9 +2,9 @@ define(['./internal/createAggregator'], function(createAggregator) { /** * Creates an array of elements split into two groups, the first of which - * contains elements `predicate` returns truthy for, while the second of which - * contains elements `predicate` returns falsey for. The predicate is invoked - * with three arguments: (value, index|key, collection). + * contains elements `predicate` returns truthy for, the second of which + * contains elements `predicate` returns falsey for. The predicate is + * invoked with one argument: (value). * * @static * @memberOf _ diff --git a/pickBy.js b/pickBy.js index 7db42ca8f..0f02d6012 100644 --- a/pickBy.js +++ b/pickBy.js @@ -18,7 +18,7 @@ define(['./internal/baseIteratee', './internal/basePickBy'], function(baseIterat * // => { 'a': 1, 'c': 3 } */ function pickBy(object, predicate) { - return object == null ? {} : basePickBy(object, baseIteratee(predicate)); + return object == null ? {} : basePickBy(object, baseIteratee(predicate, 2)); } return pickBy; diff --git a/pullAll.js b/pullAll.js index b4c6fbf9b..70b7ef419 100644 --- a/pullAll.js +++ b/pullAll.js @@ -15,7 +15,7 @@ define(['./internal/basePullAll'], function(basePullAll) { * * var array = [1, 2, 3, 1, 2, 3]; * - * _.pull(array, [2, 3]); + * _.pullAll(array, [2, 3]); * console.log(array); * // => [1, 1] */ diff --git a/range.js b/range.js index 6b55a1bfa..fcdf8d5f9 100644 --- a/range.js +++ b/range.js @@ -4,8 +4,7 @@ define(['./internal/createRange'], function(createRange) { * Creates an array of numbers (positive and/or negative) progressing from * `start` up to, but not including, `end`. A step of `-1` is used if a negative * `start` is specified without an `end` or `step`. If `end` is not specified - * it's set to `start` with `start` then set to `0`. If `end` is less than - * `start` a zero-length range is created unless a negative `step` is specified. + * it's set to `start` with `start` then set to `0`. * * **Note:** JavaScript follows the IEEE-754 standard for resolving * floating-point values which can produce unexpected results. diff --git a/reduce.js b/reduce.js index 3bd09e303..f3c2d822b 100644 --- a/reduce.js +++ b/reduce.js @@ -37,9 +37,9 @@ define(['./internal/arrayReduce', './internal/baseEach', './internal/baseIterate */ function reduce(collection, iteratee, accumulator) { var func = isArray(collection) ? arrayReduce : baseReduce, - initFromCollection = arguments.length < 3; + initAccum = arguments.length < 3; - return func(collection, baseIteratee(iteratee, 4), accumulator, initFromCollection, baseEach); + return func(collection, baseIteratee(iteratee, 4), accumulator, initAccum, baseEach); } return reduce; diff --git a/reduceRight.js b/reduceRight.js index e93d5b609..98dbe2886 100644 --- a/reduceRight.js +++ b/reduceRight.js @@ -22,9 +22,9 @@ define(['./internal/arrayReduceRight', './internal/baseEachRight', './internal/b */ function reduceRight(collection, iteratee, accumulator) { var func = isArray(collection) ? arrayReduceRight : baseReduce, - initFromCollection = arguments.length < 3; + initAccum = arguments.length < 3; - return func(collection, baseIteratee(iteratee, 4), accumulator, initFromCollection, baseEachRight); + return func(collection, baseIteratee(iteratee, 4), accumulator, initAccum, baseEachRight); } return reduceRight; diff --git a/reverse.js b/reverse.js index 0bc531a86..6f4ba3ca5 100644 --- a/reverse.js +++ b/reverse.js @@ -13,6 +13,7 @@ define([], function() { * **Note:** This method mutates `array` and is based on * [`Array#reverse`](https://mdn.io/Array/reverse). * + * @static * @memberOf _ * @category Array * @returns {Array} Returns `array`. diff --git a/sampleSize.js b/sampleSize.js index 7d7acad4f..55e96e5be 100644 --- a/sampleSize.js +++ b/sampleSize.js @@ -1,7 +1,8 @@ define(['./internal/baseClamp', './internal/baseRandom', './toArray', './toInteger'], function(baseClamp, baseRandom, toArray, toInteger) { /** - * Gets `n` random elements from `collection`. + * Gets `n` random elements at unique keys from `collection` up to the + * size of `collection`. * * @static * @memberOf _ @@ -11,8 +12,11 @@ define(['./internal/baseClamp', './internal/baseRandom', './toArray', './toInteg * @returns {Array} Returns the random elements. * @example * - * _.sampleSize([1, 2, 3, 4], 2); + * _.sampleSize([1, 2, 3], 2); * // => [3, 1] + * + * _.sampleSize([1, 2, 3], 4); + * // => [2, 3, 1] */ function sampleSize(collection, n) { var index = -1, diff --git a/toArray.js b/toArray.js index d28ab0764..042d3256b 100644 --- a/toArray.js +++ b/toArray.js @@ -1,4 +1,4 @@ -define(['./internal/_Symbol', './internal/copyArray', './internal/getTag', './isArrayLike', './isString', './internal/iteratorToArray', './internal/mapToArray', './internal/setToArray', './internal/stringToArray', './values'], function(_Symbol, copyArray, getTag, isArrayLike, isString, iteratorToArray, mapToArray, setToArray, stringToArray, values) { +define(['./internal/Symbol', './internal/copyArray', './internal/getTag', './isArrayLike', './isString', './internal/iteratorToArray', './internal/mapToArray', './internal/setToArray', './internal/stringToArray', './values'], function(Symbol, copyArray, getTag, isArrayLike, isString, iteratorToArray, mapToArray, setToArray, stringToArray, values) { /** Used as a safe reference for `undefined` in pre-ES5 environments. */ var undefined; @@ -8,7 +8,7 @@ define(['./internal/_Symbol', './internal/copyArray', './internal/getTag', './is setTag = '[object Set]'; /** Built-in value references. */ - var iteratorSymbol = typeof (iteratorSymbol = _Symbol && _Symbol.iterator) == 'symbol' ? iteratorSymbol : undefined; + var iteratorSymbol = typeof (iteratorSymbol = Symbol && Symbol.iterator) == 'symbol' ? iteratorSymbol : undefined; /** * Converts `value` to an array. diff --git a/toLength.js b/toLength.js index d74663d29..fd102c580 100644 --- a/toLength.js +++ b/toLength.js @@ -13,7 +13,7 @@ define(['./internal/baseClamp', './toInteger'], function(baseClamp, toInteger) { * @memberOf _ * @category Lang * @param {*} value The value to convert. - * @return {number} Returns the converted integer. + * @returns {number} Returns the converted integer. * @example * * _.toLength(3); diff --git a/toString.js b/toString.js index 855703c69..5f00dc45e 100644 --- a/toString.js +++ b/toString.js @@ -1,4 +1,4 @@ -define(['./internal/_Symbol', './isSymbol'], function(_Symbol, isSymbol) { +define(['./internal/Symbol', './isSymbol'], function(Symbol, isSymbol) { /** Used as a safe reference for `undefined` in pre-ES5 environments. */ var undefined; @@ -7,8 +7,8 @@ define(['./internal/_Symbol', './isSymbol'], function(_Symbol, isSymbol) { var INFINITY = 1 / 0; /** Used to convert symbols to primitives and strings. */ - var symbolProto = _Symbol ? _Symbol.prototype : undefined, - symbolToString = _Symbol ? symbolProto.toString : undefined; + var symbolProto = Symbol ? Symbol.prototype : undefined, + symbolToString = Symbol ? symbolProto.toString : undefined; /** * Converts `value` to a string if it's not one. An empty string is returned @@ -39,7 +39,7 @@ define(['./internal/_Symbol', './isSymbol'], function(_Symbol, isSymbol) { return ''; } if (isSymbol(value)) { - return _Symbol ? symbolToString.call(value) : ''; + return Symbol ? symbolToString.call(value) : ''; } var result = (value + ''); return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result; diff --git a/truncate.js b/truncate.js index 620d66e05..e95617c8e 100644 --- a/truncate.js +++ b/truncate.js @@ -12,14 +12,15 @@ define(['./isObject', './isRegExp', './internal/stringSize', './internal/stringT /** Used to compose unicode character classes. */ var rsAstralRange = '\\ud800-\\udfff', - rsComboRange = '\\u0300-\\u036f\\ufe20-\\ufe23', + rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23', + rsComboSymbolsRange = '\\u20d0-\\u20f0', rsVarRange = '\\ufe0e\\ufe0f'; /** Used to compose unicode capture groups. */ var rsZWJ = '\\u200d'; /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ - var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']'); + var reHasComplexSymbol = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']'); /** * Truncates `string` if it's longer than the given maximum string length. diff --git a/words.js b/words.js index 53cc30a8c..dfc0e839f 100644 --- a/words.js +++ b/words.js @@ -5,6 +5,8 @@ define(['./toString'], function(toString) { /** Used to compose unicode character classes. */ var rsAstralRange = '\\ud800-\\udfff', + rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23', + rsComboSymbolsRange = '\\u20d0-\\u20f0', rsDingbatRange = '\\u2700-\\u27bf', rsLowerRange = 'a-z\\xdf-\\xf6\\xf8-\\xff', rsMathOpRange = '\\xac\\xb1\\xd7\\xf7', @@ -17,11 +19,13 @@ define(['./toString'], function(toString) { /** Used to compose unicode capture groups. */ var rsBreak = '[' + rsBreakRange + ']', + rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']', rsDigits = '\\d+', rsDingbat = '[' + rsDingbatRange + ']', rsLower = '[' + rsLowerRange + ']', rsMisc = '[^' + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + ']', - rsModifier = '(?:\\ud83c[\\udffb-\\udfff])', + rsFitz = '\\ud83c[\\udffb-\\udfff]', + rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')', rsNonAstral = '[^' + rsAstralRange + ']', rsRegional = '(?:\\ud83c[\\udde6-\\uddff]){2}', rsSurrPair = '[\\ud800-\\udbff][\\udc00-\\udfff]', @@ -45,7 +49,8 @@ define(['./toString'], function(toString) { rsUpper + '?' + rsLower + '+(?=' + [rsBreak, rsUpper, '$'].join('|') + ')', rsUpperMisc + '+(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')', rsUpper + '?' + rsLowerMisc + '+', - rsDigits + '(?:' + rsLowerMisc + '+)?', + rsUpper + '+', + rsDigits, rsEmoji ].join('|'), 'g'); diff --git a/wrapperFlatMap.js b/wrapperFlatMap.js index 3bf19290b..9fd432134 100644 --- a/wrapperFlatMap.js +++ b/wrapperFlatMap.js @@ -3,7 +3,7 @@ define([], function() { /** * This method is the wrapper version of `_.flatMap`. * - * @static + * @name flatMap * @memberOf _ * @category Seq * @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration. diff --git a/wrapperLodash.js b/wrapperLodash.js index 66911d39c..fb37d5775 100644 --- a/wrapperLodash.js +++ b/wrapperLodash.js @@ -47,13 +47,12 @@ define(['./internal/LazyWrapper', './internal/LodashWrapper', './internal/baseLo * The chainable wrapper methods are: * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, * `at`, `before`, `bind`, `bindAll`, `bindKey`, `chain`, `chunk`, `commit`, - * `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, `curry`, + * `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, `curry`, * `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, `difference`, - * `differenceBy`, `differenceWith`, `drop`, `dropRight`, `dropRightWhile`, + * `differenceBy`, `differenceWith`, `drop`, `dropRight`, `dropRightWhile`, * `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flip`, `flow`, - * `flowRight`, `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, - * `forOwnRight`, `fromPairs`, `functions`, `functionsIn`, `groupBy`, `initial`, - * `intersection`, `intersectionBy`, `intersectionWith`, invert`, `invokeMap`, + * `flowRight`, `fromPairs`, `functions`, `functionsIn`, `groupBy`, `initial`, + * `intersection`, `intersectionBy`, `intersectionWith`, `invert`, `invokeMap`, * `iteratee`, `keyBy`, `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, * `matches`, `matchesProperty`, `memoize`, `merge`, `mergeWith`, `method`, * `methodOf`, `mixin`, `negate`, `nthArg`, `omit`, `omitBy`, `once`, `orderBy`, @@ -72,22 +71,23 @@ define(['./internal/LazyWrapper', './internal/LodashWrapper', './internal/baseLo * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`, * `cloneDeep`, `cloneDeepWith`, `cloneWith`, `deburr`, `endsWith`, `eq`, * `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, - * `findLast`, `findLastIndex`, `findLastKey`, `floor`, `get`, `gt`, `gte`, - * `has`, `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, - * `invoke`, `isArguments`, `isArray`, `isArrayLike`, `isArrayLikeObject`, - * `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, - * `isError`, `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMatch`, - * `isMatchWith`, `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, - * `isObject`, `isObjectLike`, `isPlainObject`, `isRegExp`, `isSafeInteger`, - * `isString`, `isUndefined`, `isTypedArray`, `join`, `kebabCase`, `last`, - * `lastIndexOf`, `lowerCase`, `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, - * `mean`, `min`, `minBy`, `noConflict`, `noop`, `now`, `pad`, `padEnd`, - * `padStart`, `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, `repeat`, - * `result`, `round`, `runInContext`, `sample`, `shift`, `size`, `snakeCase`, - * `some`, `sortedIndex`, `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`, - * `startCase`, `startsWith`, `subtract`, `sum`, sumBy`, `template`, `times`, - * `toLower`, `toInteger`, `toLength`, `toNumber`, `toSafeInteger`, toString`, - * `toUpper`, `trim`, `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, + * `findLast`, `findLastIndex`, `findLastKey`, `floor`, `forEach`, `forEachRight`, + * `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `get`, `gt`, `gte`, `has`, + * `hasIn`, `head`, `identity`, `includes`, `indexOf`, `inRange`, `invoke`, + * `isArguments`, `isArray`, `isArrayLike`, `isArrayLikeObject`, `isBoolean`, + * `isDate`, `isElement`, `isEmpty`, `isEqual`, `isEqualWith`, `isError`, + * `isFinite`, `isFunction`, `isInteger`, `isLength`, `isMatch`, `isMatchWith`, + * `isNaN`, `isNative`, `isNil`, `isNull`, `isNumber`, `isObject`, `isObjectLike`, + * `isPlainObject`, `isRegExp`, `isSafeInteger`, `isString`, `isUndefined`, + * `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `lowerCase`, + * `lowerFirst`, `lt`, `lte`, `max`, `maxBy`, `mean`, `min`, `minBy`, + * `noConflict`, `noop`, `now`, `pad`, `padEnd`, `padStart`, `parseInt`, + * `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, `round`, + * `runInContext`, `sample`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, + * `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`, `startCase`, + * `startsWith`, `subtract`, `sum`, `sumBy`, `template`, `times`, `toLower`, + * `toInteger`, `toLength`, `toNumber`, `toSafeInteger`, `toString`, `toUpper`, + * `trim`, `trimEnd`, `trimStart`, `truncate`, `unescape`, `uniqueId`, * `upperCase`, `upperFirst`, `value`, and `words` * * @name _ diff --git a/wrapperValue.js b/wrapperValue.js index ab58313f3..602c715c8 100644 --- a/wrapperValue.js +++ b/wrapperValue.js @@ -5,7 +5,7 @@ define(['./internal/baseWrapperValue'], function(baseWrapperValue) { * * @name value * @memberOf _ - * @alias run, toJSON, valueOf + * @alias toJSON, valueOf * @category Seq * @returns {*} Returns the resolved unwrapped value. * @example