diff --git a/README.md b/README.md
index 1ebcd20ea..ef6a0dfd7 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# lodash-es v4.1.0
+# lodash-es v4.2.0
The [lodash](https://lodash.com/) library exported as [ES](http://www.ecma-international.org/ecma-262/6.0/) modules.
@@ -7,4 +7,4 @@ Generated using [lodash-cli](https://www.npmjs.com/package/lodash-cli):
$ lodash modularize exports=es -o ./
```
-See the [package source](https://github.com/lodash/lodash/tree/4.1.0-es) for more details.
+See the [package source](https://github.com/lodash/lodash/tree/4.2.0-es) for more details.
diff --git a/_apply.js b/_apply.js
index 28994b185..341315948 100644
--- a/_apply.js
+++ b/_apply.js
@@ -5,11 +5,11 @@
* @private
* @param {Function} func The function to invoke.
* @param {*} thisArg The `this` binding of `func`.
- * @param {...*} [args] The arguments to invoke `func` with.
+ * @param {...*} args The arguments to invoke `func` with.
* @returns {*} Returns the result of `func`.
*/
function apply(func, thisArg, args) {
- var length = args ? args.length : 0;
+ var length = args.length;
switch (length) {
case 0: return func.call(thisArg);
case 1: return func.call(thisArg, args[0]);
diff --git a/_baseSum.js b/_baseSum.js
index 3ef08537b..c0e4ea5e3 100644
--- a/_baseSum.js
+++ b/_baseSum.js
@@ -17,7 +17,7 @@ function baseSum(array, iteratee) {
result = result === undefined ? current : (result + current);
}
}
- return length ? result : 0;
+ return result;
}
export default baseSum;
diff --git a/array.default.js b/array.default.js
index 08144c241..06f864da7 100644
--- a/array.default.js
+++ b/array.default.js
@@ -11,7 +11,6 @@ import dropWhile from './dropWhile';
import fill from './fill';
import findIndex from './findIndex';
import findLastIndex from './findLastIndex';
-import flatMap from './flatMap';
import flatten from './flatten';
import flattenDeep from './flattenDeep';
import fromPairs from './fromPairs';
@@ -64,15 +63,15 @@ import zipWith from './zipWith';
export default {
chunk, compact, concat, difference, differenceBy,
differenceWith, drop, dropRight, dropRightWhile, dropWhile,
- fill, findIndex, findLastIndex, flatMap, flatten,
- flattenDeep, fromPairs, head, indexOf, initial,
- intersection, intersectionBy, intersectionWith, join, last,
- lastIndexOf, pull, pullAll, pullAllBy, pullAt,
- remove, reverse, slice, sortedIndex, sortedIndexBy,
- sortedIndexOf, sortedLastIndex, sortedLastIndexBy, sortedLastIndexOf, sortedUniq,
- sortedUniqBy, tail, take, takeRight, takeRightWhile,
- takeWhile, union, unionBy, unionWith, uniq,
- uniqBy, uniqWith, unzip, unzipWith, without,
- xor, xorBy, xorWith, zip, zipObject,
- zipObjectDeep, zipWith
+ fill, findIndex, findLastIndex, flatten, flattenDeep,
+ fromPairs, head, indexOf, initial, intersection,
+ intersectionBy, intersectionWith, join, last, lastIndexOf,
+ pull, pullAll, pullAllBy, pullAt, remove,
+ reverse, slice, sortedIndex, sortedIndexBy, sortedIndexOf,
+ sortedLastIndex, sortedLastIndexBy, sortedLastIndexOf, sortedUniq, sortedUniqBy,
+ tail, take, takeRight, takeRightWhile, takeWhile,
+ union, unionBy, unionWith, uniq, uniqBy,
+ uniqWith, unzip, unzipWith, without, xor,
+ xorBy, xorWith, zip, zipObject, zipObjectDeep,
+ zipWith
};
diff --git a/array.js b/array.js
index ef71aa4e7..0e705fbfd 100644
--- a/array.js
+++ b/array.js
@@ -11,7 +11,6 @@ export { default as dropWhile } from './dropWhile';
export { default as fill } from './fill';
export { default as findIndex } from './findIndex';
export { default as findLastIndex } from './findLastIndex';
-export { default as flatMap } from './flatMap';
export { default as flatten } from './flatten';
export { default as flattenDeep } from './flattenDeep';
export { default as fromPairs } from './fromPairs';
diff --git a/attempt.js b/attempt.js
index c93d21a96..56cc0a9c6 100644
--- a/attempt.js
+++ b/attempt.js
@@ -1,5 +1,5 @@
import apply from './_apply';
-import isError from './isError';
+import isObject from './isObject';
import rest from './rest';
/**
@@ -13,7 +13,7 @@ import rest from './rest';
* @returns {*} Returns the `func` result or error object.
* @example
*
- * // avoid throwing errors for invalid selectors
+ * // Avoid throwing errors for invalid selectors.
* var elements = _.attempt(function(selector) {
* return document.querySelectorAll(selector);
* }, '>_>');
@@ -26,7 +26,7 @@ var attempt = rest(function(func, args) {
try {
return apply(func, undefined, args);
} catch (e) {
- return isError(e) ? e : new Error(e);
+ return isObject(e) ? e : new Error(e);
}
});
diff --git a/bind.js b/bind.js
index 514a79f5d..8c9097438 100644
--- a/bind.js
+++ b/bind.js
@@ -36,7 +36,7 @@ var BIND_FLAG = 1,
* bound('!');
* // => 'hi fred!'
*
- * // using placeholders
+ * // Bound with placeholders.
* var bound = _.bind(greet, object, _, '!');
* bound('hi');
* // => 'hi fred!'
diff --git a/bindKey.js b/bindKey.js
index a98333a53..efa65adef 100644
--- a/bindKey.js
+++ b/bindKey.js
@@ -46,7 +46,7 @@ var BIND_FLAG = 1,
* bound('!');
* // => 'hiya fred!'
*
- * // using placeholders
+ * // Bound with placeholders.
* var bound = _.bindKey(object, 'greet', _, '!');
* bound('hi');
* // => 'hiya fred!'
diff --git a/collection.default.js b/collection.default.js
index 6b5cec830..0165b0367 100644
--- a/collection.default.js
+++ b/collection.default.js
@@ -6,6 +6,7 @@ import every from './every';
import filter from './filter';
import find from './find';
import findLast from './findLast';
+import flatMap from './flatMap';
import forEach from './forEach';
import forEachRight from './forEachRight';
import groupBy from './groupBy';
@@ -27,9 +28,9 @@ import sortBy from './sortBy';
export default {
at, countBy, each, eachRight, every,
- filter, find, findLast, forEach, forEachRight,
- groupBy, includes, invokeMap, keyBy, map,
- orderBy, partition, reduce, reduceRight, reject,
- sample, sampleSize, shuffle, size, some,
- sortBy
+ filter, find, findLast, flatMap, forEach,
+ forEachRight, groupBy, includes, invokeMap, keyBy,
+ map, orderBy, partition, reduce, reduceRight,
+ reject, sample, sampleSize, shuffle, size,
+ some, sortBy
};
diff --git a/collection.js b/collection.js
index 8dad26274..6ab3ff609 100644
--- a/collection.js
+++ b/collection.js
@@ -6,6 +6,7 @@ export { default as every } from './every';
export { default as filter } from './filter';
export { default as find } from './find';
export { default as findLast } from './findLast';
+export { default as flatMap } from './flatMap';
export { default as forEach } from './forEach';
export { default as forEachRight } from './forEachRight';
export { default as groupBy } from './groupBy';
diff --git a/curry.js b/curry.js
index eb16cb00a..4c0b97919 100644
--- a/curry.js
+++ b/curry.js
@@ -39,7 +39,7 @@ var CURRY_FLAG = 8;
* curried(1, 2, 3);
* // => [1, 2, 3]
*
- * // using placeholders
+ * // Curried with placeholders.
* curried(1)(_, 3)(2);
* // => [1, 2, 3]
*/
diff --git a/curryRight.js b/curryRight.js
index ba2daa86e..32c5be3cd 100644
--- a/curryRight.js
+++ b/curryRight.js
@@ -36,7 +36,7 @@ var CURRY_RIGHT_FLAG = 16;
* curried(1, 2, 3);
* // => [1, 2, 3]
*
- * // using placeholders
+ * // Curried with placeholders.
* curried(3)(1, _)(2);
* // => [1, 2, 3]
*/
diff --git a/debounce.js b/debounce.js
index 8d2a325a6..038f9f3c6 100644
--- a/debounce.js
+++ b/debounce.js
@@ -40,21 +40,21 @@ var nativeMax = Math.max;
* @returns {Function} Returns the new debounced function.
* @example
*
- * // avoid costly calculations while the window size is in flux
+ * // Avoid costly calculations while the window size is in flux.
* jQuery(window).on('resize', _.debounce(calculateLayout, 150));
*
- * // invoke `sendMail` when clicked, debouncing subsequent calls
+ * // Invoke `sendMail` when clicked, debouncing subsequent calls.
* jQuery(element).on('click', _.debounce(sendMail, 300, {
* 'leading': true,
* 'trailing': false
* }));
*
- * // ensure `batchLog` is invoked once after 1 second of debounced calls
+ * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
* var source = new EventSource('/stream');
* jQuery(source).on('message', debounced);
*
- * // cancel a trailing debounced invocation
+ * // Cancel the trailing debounced invocation.
* jQuery(window).on('popstate', debounced.cancel);
*/
function debounce(func, wait, options) {
diff --git a/defer.js b/defer.js
index 4178ba121..b0f6caffa 100644
--- a/defer.js
+++ b/defer.js
@@ -16,7 +16,7 @@ import rest from './rest';
* _.defer(function(text) {
* console.log(text);
* }, 'deferred');
- * // logs 'deferred' after one or more milliseconds
+ * // => logs 'deferred' after one or more milliseconds
*/
var defer = rest(function(func, args) {
return baseDelay(func, 1, args);
diff --git a/differenceBy.js b/differenceBy.js
index 9eb6af8ad..dddbf9b33 100644
--- a/differenceBy.js
+++ b/differenceBy.js
@@ -22,7 +22,7 @@ import rest from './rest';
* _.differenceBy([3.1, 2.2, 1.3], [4.4, 2.5], Math.floor);
* // => [3.1, 1.3]
*
- * // using the `_.property` iteratee shorthand
+ * // The `_.property` iteratee shorthand.
* _.differenceBy([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
* // => [{ 'x': 2 }]
*/
diff --git a/dropRightWhile.js b/dropRightWhile.js
index f61229941..b870ba003 100644
--- a/dropRightWhile.js
+++ b/dropRightWhile.js
@@ -23,15 +23,15 @@ import baseWhile from './_baseWhile';
* _.dropRightWhile(users, function(o) { return !o.active; });
* // => objects for ['barney']
*
- * // using the `_.matches` iteratee shorthand
+ * // The `_.matches` iteratee shorthand.
* _.dropRightWhile(users, { 'user': 'pebbles', 'active': false });
* // => objects for ['barney', 'fred']
*
- * // using the `_.matchesProperty` iteratee shorthand
+ * // The `_.matchesProperty` iteratee shorthand.
* _.dropRightWhile(users, ['active', false]);
* // => objects for ['barney']
*
- * // using the `_.property` iteratee shorthand
+ * // The `_.property` iteratee shorthand.
* _.dropRightWhile(users, 'active');
* // => objects for ['barney', 'fred', 'pebbles']
*/
diff --git a/dropWhile.js b/dropWhile.js
index b029843e9..850932af4 100644
--- a/dropWhile.js
+++ b/dropWhile.js
@@ -23,15 +23,15 @@ import baseWhile from './_baseWhile';
* _.dropWhile(users, function(o) { return !o.active; });
* // => objects for ['pebbles']
*
- * // using the `_.matches` iteratee shorthand
+ * // The `_.matches` iteratee shorthand.
* _.dropWhile(users, { 'user': 'barney', 'active': false });
* // => objects for ['fred', 'pebbles']
*
- * // using the `_.matchesProperty` iteratee shorthand
+ * // The `_.matchesProperty` iteratee shorthand.
* _.dropWhile(users, ['active', false]);
* // => objects for ['pebbles']
*
- * // using the `_.property` iteratee shorthand
+ * // The `_.property` iteratee shorthand.
* _.dropWhile(users, 'active');
* // => objects for ['barney', 'fred', 'pebbles']
*/
diff --git a/every.js b/every.js
index f69f245a4..75e575167 100644
--- a/every.js
+++ b/every.js
@@ -26,15 +26,15 @@ import isIterateeCall from './_isIterateeCall';
* { 'user': 'fred', 'active': false }
* ];
*
- * // using the `_.matches` iteratee shorthand
+ * // The `_.matches` iteratee shorthand.
* _.every(users, { 'user': 'barney', 'active': false });
* // => false
*
- * // using the `_.matchesProperty` iteratee shorthand
+ * // The `_.matchesProperty` iteratee shorthand.
* _.every(users, ['active', false]);
* // => true
*
- * // using the `_.property` iteratee shorthand
+ * // The `_.property` iteratee shorthand.
* _.every(users, 'active');
* // => false
*/
diff --git a/filter.js b/filter.js
index 5a646550b..61f87e9ec 100644
--- a/filter.js
+++ b/filter.js
@@ -24,15 +24,15 @@ import isArray from './isArray';
* _.filter(users, function(o) { return !o.active; });
* // => objects for ['fred']
*
- * // using the `_.matches` iteratee shorthand
+ * // The `_.matches` iteratee shorthand.
* _.filter(users, { 'age': 36, 'active': true });
* // => objects for ['barney']
*
- * // using the `_.matchesProperty` iteratee shorthand
+ * // The `_.matchesProperty` iteratee shorthand.
* _.filter(users, ['active', false]);
* // => objects for ['fred']
*
- * // using the `_.property` iteratee shorthand
+ * // The `_.property` iteratee shorthand.
* _.filter(users, 'active');
* // => objects for ['barney']
*/
diff --git a/find.js b/find.js
index 2022d741a..210970c9a 100644
--- a/find.js
+++ b/find.js
@@ -26,15 +26,15 @@ import isArray from './isArray';
* _.find(users, function(o) { return o.age < 40; });
* // => object for 'barney'
*
- * // using the `_.matches` iteratee shorthand
+ * // The `_.matches` iteratee shorthand.
* _.find(users, { 'age': 1, 'active': true });
* // => object for 'pebbles'
*
- * // using the `_.matchesProperty` iteratee shorthand
+ * // The `_.matchesProperty` iteratee shorthand.
* _.find(users, ['active', false]);
* // => object for 'fred'
*
- * // using the `_.property` iteratee shorthand
+ * // The `_.property` iteratee shorthand.
* _.find(users, 'active');
* // => object for 'barney'
*/
diff --git a/findIndex.js b/findIndex.js
index 4d46e0522..ee6363708 100644
--- a/findIndex.js
+++ b/findIndex.js
@@ -22,15 +22,15 @@ import baseIteratee from './_baseIteratee';
* _.findIndex(users, function(o) { return o.user == 'barney'; });
* // => 0
*
- * // using the `_.matches` iteratee shorthand
+ * // The `_.matches` iteratee shorthand.
* _.findIndex(users, { 'user': 'fred', 'active': false });
* // => 1
*
- * // using the `_.matchesProperty` iteratee shorthand
+ * // The `_.matchesProperty` iteratee shorthand.
* _.findIndex(users, ['active', false]);
* // => 0
*
- * // using the `_.property` iteratee shorthand
+ * // The `_.property` iteratee shorthand.
* _.findIndex(users, 'active');
* // => 2
*/
diff --git a/findKey.js b/findKey.js
index 2f4e5990a..ddd6bfa89 100644
--- a/findKey.js
+++ b/findKey.js
@@ -23,15 +23,15 @@ import baseIteratee from './_baseIteratee';
* _.findKey(users, function(o) { return o.age < 40; });
* // => 'barney' (iteration order is not guaranteed)
*
- * // using the `_.matches` iteratee shorthand
+ * // The `_.matches` iteratee shorthand.
* _.findKey(users, { 'age': 1, 'active': true });
* // => 'pebbles'
*
- * // using the `_.matchesProperty` iteratee shorthand
+ * // The `_.matchesProperty` iteratee shorthand.
* _.findKey(users, ['active', false]);
* // => 'fred'
*
- * // using the `_.property` iteratee shorthand
+ * // The `_.property` iteratee shorthand.
* _.findKey(users, 'active');
* // => 'barney'
*/
diff --git a/findLastIndex.js b/findLastIndex.js
index fbdd3954b..4d1a5138b 100644
--- a/findLastIndex.js
+++ b/findLastIndex.js
@@ -22,15 +22,15 @@ import baseIteratee from './_baseIteratee';
* _.findLastIndex(users, function(o) { return o.user == 'pebbles'; });
* // => 2
*
- * // using the `_.matches` iteratee shorthand
+ * // The `_.matches` iteratee shorthand.
* _.findLastIndex(users, { 'user': 'barney', 'active': true });
* // => 0
*
- * // using the `_.matchesProperty` iteratee shorthand
+ * // The `_.matchesProperty` iteratee shorthand.
* _.findLastIndex(users, ['active', false]);
* // => 2
*
- * // using the `_.property` iteratee shorthand
+ * // The `_.property` iteratee shorthand.
* _.findLastIndex(users, 'active');
* // => 0
*/
diff --git a/findLastKey.js b/findLastKey.js
index 2499a67ba..d5f78412f 100644
--- a/findLastKey.js
+++ b/findLastKey.js
@@ -23,15 +23,15 @@ import baseIteratee from './_baseIteratee';
* _.findLastKey(users, function(o) { return o.age < 40; });
* // => returns 'pebbles' assuming `_.findKey` returns 'barney'
*
- * // using the `_.matches` iteratee shorthand
+ * // The `_.matches` iteratee shorthand.
* _.findLastKey(users, { 'age': 36, 'active': true });
* // => 'barney'
*
- * // using the `_.matchesProperty` iteratee shorthand
+ * // The `_.matchesProperty` iteratee shorthand.
* _.findLastKey(users, ['active', false]);
* // => 'fred'
*
- * // using the `_.property` iteratee shorthand
+ * // The `_.property` iteratee shorthand.
* _.findLastKey(users, 'active');
* // => 'pebbles'
*/
diff --git a/flatMap.js b/flatMap.js
index 6d8177c54..34959f609 100644
--- a/flatMap.js
+++ b/flatMap.js
@@ -1,18 +1,17 @@
-import arrayMap from './_arrayMap';
import baseFlatten from './_baseFlatten';
-import baseIteratee from './_baseIteratee';
+import map from './map';
/**
- * Creates an array of flattened values by running each element in `array`
+ * Creates an array of flattened values by running each element in `collection`
* through `iteratee` and concating its result to the other mapped values.
- * The iteratee is invoked with three arguments: (value, index|key, array).
+ * The iteratee is invoked with three arguments: (value, index|key, collection).
*
* @static
* @memberOf _
- * @category Array
- * @param {Array} array The array to iterate over.
+ * @category Collection
+ * @param {Array|Object} collection The collection to iterate over.
* @param {Function|Object|string} [iteratee=_.identity] The function invoked per iteration.
- * @returns {Array} Returns the new array.
+ * @returns {Array} Returns the new flattened array.
* @example
*
* function duplicate(n) {
@@ -22,9 +21,8 @@ import baseIteratee from './_baseIteratee';
* _.flatMap([1, 2], duplicate);
* // => [1, 1, 2, 2]
*/
-function flatMap(array, iteratee) {
- var length = array ? array.length : 0;
- return length ? baseFlatten(arrayMap(array, baseIteratee(iteratee, 3))) : [];
+function flatMap(collection, iteratee) {
+ return baseFlatten(map(collection, iteratee));
}
export default flatMap;
diff --git a/groupBy.js b/groupBy.js
index e913b8d16..3fa4106c7 100644
--- a/groupBy.js
+++ b/groupBy.js
@@ -23,7 +23,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
* _.groupBy([6.1, 4.2, 6.3], Math.floor);
* // => { '4': [4.2], '6': [6.1, 6.3] }
*
- * // using the `_.property` iteratee shorthand
+ * // The `_.property` iteratee shorthand.
* _.groupBy(['one', 'two', 'three'], 'length');
* // => { '3': ['one', 'two'], '5': ['three'] }
*/
diff --git a/indexOf.js b/indexOf.js
index 1b395acc2..a10088f5d 100644
--- a/indexOf.js
+++ b/indexOf.js
@@ -8,8 +8,7 @@ var nativeMax = Math.max;
* 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)
* for equality comparisons. If `fromIndex` is negative, it's used as the offset
- * from the end of `array`. If `array` is sorted providing `true` for `fromIndex`
- * performs a faster binary search.
+ * from the end of `array`.
*
* @static
* @memberOf _
@@ -23,7 +22,7 @@ var nativeMax = Math.max;
* _.indexOf([1, 2, 1, 2], 2);
* // => 1
*
- * // using `fromIndex`
+ * // Search from the `fromIndex`.
* _.indexOf([1, 2, 1, 2], 2, 2);
* // => 3
*/
diff --git a/intersectionBy.js b/intersectionBy.js
index 6201dc1a9..af686e4b7 100644
--- a/intersectionBy.js
+++ b/intersectionBy.js
@@ -21,7 +21,7 @@ import toArrayLikeObject from './_toArrayLikeObject';
* _.intersectionBy([2.1, 1.2], [4.3, 2.4], Math.floor);
* // => [2.1]
*
- * // using the `_.property` iteratee shorthand
+ * // The `_.property` iteratee shorthand.
* _.intersectionBy([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 1 }]
*/
diff --git a/iteratee.js b/iteratee.js
index 285459f10..56344d7cf 100644
--- a/iteratee.js
+++ b/iteratee.js
@@ -1,7 +1,5 @@
+import baseClone from './_baseClone';
import baseIteratee from './_baseIteratee';
-import isArray from './isArray';
-import isObjectLike from './isObjectLike';
-import matches from './matches';
/**
* Creates a function that invokes `func` with the arguments of the created
@@ -21,7 +19,7 @@ import matches from './matches';
* { 'user': 'fred', 'age': 40 }
* ];
*
- * // create custom iteratee shorthands
+ * // Create custom iteratee shorthands.
* _.iteratee = _.wrap(_.iteratee, function(callback, func) {
* var p = /^(\S+)\s*([<>])\s*(\S+)$/.exec(func);
* return !p ? callback(func) : function(object) {
@@ -33,9 +31,7 @@ import matches from './matches';
* // => [{ 'user': 'fred', 'age': 40 }]
*/
function iteratee(func) {
- return (isObjectLike(func) && !isArray(func))
- ? matches(func)
- : baseIteratee(func);
+ return baseIteratee(typeof func == 'function' ? func : baseClone(func, true));
}
export default iteratee;
diff --git a/lastIndexOf.js b/lastIndexOf.js
index 3157ef3b3..217006661 100644
--- a/lastIndexOf.js
+++ b/lastIndexOf.js
@@ -21,7 +21,7 @@ var nativeMax = Math.max,
* _.lastIndexOf([1, 2, 1, 2], 2);
* // => 3
*
- * // using `fromIndex`
+ * // Search from the `fromIndex`.
* _.lastIndexOf([1, 2, 1, 2], 2, 2);
* // => 1
*/
diff --git a/lodash.default.js b/lodash.default.js
index 92859581d..ba7379be4 100644
--- a/lodash.default.js
+++ b/lodash.default.js
@@ -1,6 +1,6 @@
/**
* @license
- * lodash 4.1.0 (Custom Build)
+ * lodash 4.2.0 (Custom Build)
* Build: `lodash modularize exports="es" -o ./`
* Copyright 2012-2016 The Dojo Foundation
* Based on Underscore.js 1.8.3
@@ -44,7 +44,7 @@ import toInteger from './toInteger';
import lodash from './wrapperLodash';
/** Used as the semantic version number. */
-var VERSION = '4.1.0';
+var VERSION = '4.2.0';
/** Used to compose bitmasks for wrapper metadata. */
var BIND_KEY_FLAG = 2;
@@ -125,7 +125,7 @@ lodash.dropRightWhile = array.dropRightWhile;
lodash.dropWhile = array.dropWhile;
lodash.fill = array.fill;
lodash.filter = collection.filter;
-lodash.flatMap = array.flatMap;
+lodash.flatMap = collection.flatMap;
lodash.flatten = array.flatten;
lodash.flattenDeep = array.flattenDeep;
lodash.flip = func.flip;
diff --git a/lodash.js b/lodash.js
index 8851f4ad1..725b02360 100644
--- a/lodash.js
+++ b/lodash.js
@@ -1,6 +1,6 @@
/**
* @license
- * lodash 4.1.0 (Custom Build)
+ * lodash 4.2.0 (Custom Build)
* Build: `lodash modularize exports="es" -o ./`
* Copyright 2012-2016 The Dojo Foundation
* Based on Underscore.js 1.8.3
diff --git a/map.js b/map.js
index e41fca95e..eef729742 100644
--- a/map.js
+++ b/map.js
@@ -40,7 +40,7 @@ import isArray from './isArray';
* { 'user': 'fred' }
* ];
*
- * // using the `_.property` iteratee shorthand
+ * // The `_.property` iteratee shorthand.
* _.map(users, 'user');
* // => ['barney', 'fred']
*/
diff --git a/mapValues.js b/mapValues.js
index 75478dd8d..86b6957d5 100644
--- a/mapValues.js
+++ b/mapValues.js
@@ -22,7 +22,7 @@ import baseIteratee from './_baseIteratee';
* _.mapValues(users, function(o) { return o.age; });
* // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
*
- * // using the `_.property` iteratee shorthand
+ * // The `_.property` iteratee shorthand.
* _.mapValues(users, 'age');
* // => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
*/
diff --git a/maxBy.js b/maxBy.js
index b43221569..107cb8434 100644
--- a/maxBy.js
+++ b/maxBy.js
@@ -20,7 +20,7 @@ import gt from './gt';
* _.maxBy(objects, function(o) { return o.n; });
* // => { 'n': 2 }
*
- * // using the `_.property` iteratee shorthand
+ * // The `_.property` iteratee shorthand.
* _.maxBy(objects, 'n');
* // => { 'n': 2 }
*/
diff --git a/memoize.js b/memoize.js
index 4fc43356b..d59456999 100644
--- a/memoize.js
+++ b/memoize.js
@@ -37,12 +37,12 @@ var FUNC_ERROR_TEXT = 'Expected a function';
* values(object);
* // => [1, 2]
*
- * // modifying the result cache
+ * // Modify the result cache.
* values.cache.set(object, ['a', 'b']);
* values(object);
* // => ['a', 'b']
*
- * // replacing `_.memoize.Cache`
+ * // Replace `_.memoize.Cache`.
* _.memoize.Cache = WeakMap;
*/
function memoize(func, resolver) {
diff --git a/mergeWith.js b/mergeWith.js
index 508bc10bd..8d069fe47 100644
--- a/mergeWith.js
+++ b/mergeWith.js
@@ -8,6 +8,8 @@ import createAssigner from './_createAssigner';
* method instead. The `customizer` is invoked with seven arguments:
* (objValue, srcValue, key, object, source, stack).
*
+ * **Note:** This method mutates `object`.
+ *
* @static
* @memberOf _
* @category Object
diff --git a/minBy.js b/minBy.js
index 1edb69fc7..6cb4e8776 100644
--- a/minBy.js
+++ b/minBy.js
@@ -20,7 +20,7 @@ import lt from './lt';
* _.minBy(objects, function(o) { return o.n; });
* // => { 'n': 1 }
*
- * // using the `_.property` iteratee shorthand
+ * // The `_.property` iteratee shorthand.
* _.minBy(objects, 'n');
* // => { 'n': 1 }
*/
diff --git a/orderBy.js b/orderBy.js
index 94dd9ae22..accb47c26 100644
--- a/orderBy.js
+++ b/orderBy.js
@@ -24,7 +24,7 @@ import isArray from './isArray';
* { 'user': 'barney', 'age': 36 }
* ];
*
- * // sort by `user` in ascending order and by `age` in descending order
+ * // Sort by `user` in ascending order and by `age` in descending order.
* _.orderBy(users, ['user', 'age'], ['asc', 'desc']);
* // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]]
*/
diff --git a/package.json b/package.json
index 17a6fe3a1..d85e52466 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "lodash-es",
- "version": "4.1.0",
+ "version": "4.2.0",
"description": "Lodash exported as ES modules.",
"homepage": "https://lodash.com/custom-builds",
"license": "MIT",
diff --git a/partial.js b/partial.js
index 8de56f127..98dc748d9 100644
--- a/partial.js
+++ b/partial.js
@@ -32,7 +32,7 @@ var PARTIAL_FLAG = 32;
* sayHelloTo('fred');
* // => 'hello fred'
*
- * // using placeholders
+ * // Partially applied with placeholders.
* var greetFred = _.partial(greet, _, 'fred');
* greetFred('hi');
* // => 'hi fred'
diff --git a/partialRight.js b/partialRight.js
index 9c09f49e6..158fabf29 100644
--- a/partialRight.js
+++ b/partialRight.js
@@ -31,7 +31,7 @@ var PARTIAL_RIGHT_FLAG = 64;
* greetFred('hi');
* // => 'hi fred'
*
- * // using placeholders
+ * // Partially applied with placeholders.
* var sayHelloTo = _.partialRight(greet, 'hello', _);
* sayHelloTo('fred');
* // => 'hello fred'
diff --git a/partition.js b/partition.js
index 524a8d321..bb65c837a 100644
--- a/partition.js
+++ b/partition.js
@@ -23,15 +23,15 @@ import createAggregator from './_createAggregator';
* _.partition(users, function(o) { return o.active; });
* // => objects for [['fred'], ['barney', 'pebbles']]
*
- * // using the `_.matches` iteratee shorthand
+ * // The `_.matches` iteratee shorthand.
* _.partition(users, { 'age': 1, 'active': false });
* // => objects for [['pebbles'], ['barney', 'fred']]
*
- * // using the `_.matchesProperty` iteratee shorthand
+ * // The `_.matchesProperty` iteratee shorthand.
* _.partition(users, ['active', false]);
* // => objects for [['barney', 'pebbles'], ['fred']]
*
- * // using the `_.property` iteratee shorthand
+ * // The `_.property` iteratee shorthand.
* _.partition(users, 'active');
* // => objects for [['fred'], ['barney', 'pebbles']]
*/
diff --git a/pickBy.js b/pickBy.js
index 2ec375349..109dd4115 100644
--- a/pickBy.js
+++ b/pickBy.js
@@ -3,7 +3,7 @@ import basePickBy from './_basePickBy';
/**
* Creates an object composed of the `object` properties `predicate` returns
- * truthy for. The predicate is invoked with one argument: (value).
+ * truthy for. The predicate is invoked with two arguments: (value, key).
*
* @static
* @memberOf _
diff --git a/reject.js b/reject.js
index d61f39acc..e71a39b3d 100644
--- a/reject.js
+++ b/reject.js
@@ -23,15 +23,15 @@ import isArray from './isArray';
* _.reject(users, function(o) { return !o.active; });
* // => objects for ['fred']
*
- * // using the `_.matches` iteratee shorthand
+ * // The `_.matches` iteratee shorthand.
* _.reject(users, { 'age': 40, 'active': true });
* // => objects for ['barney']
*
- * // using the `_.matchesProperty` iteratee shorthand
+ * // The `_.matchesProperty` iteratee shorthand.
* _.reject(users, ['active', false]);
* // => objects for ['fred']
*
- * // using the `_.property` iteratee shorthand
+ * // The `_.property` iteratee shorthand.
* _.reject(users, 'active');
* // => objects for ['barney']
*/
diff --git a/set.js b/set.js
index 7ae317aac..2451ce939 100644
--- a/set.js
+++ b/set.js
@@ -6,6 +6,8 @@ import baseSet from './_baseSet';
* are created for all other missing properties. Use `_.setWith` to customize
* `path` creation.
*
+ * **Note:** This method mutates `object`.
+ *
* @static
* @memberOf _
* @category Object
diff --git a/setWith.js b/setWith.js
index 700c6a702..880d64c6a 100644
--- a/setWith.js
+++ b/setWith.js
@@ -6,6 +6,8 @@ import baseSet from './_baseSet';
* path creation is handled by the method instead. The `customizer` is invoked
* with three arguments: (nsValue, key, nsObject).
*
+ * **Note:** This method mutates `object`.
+ *
* @static
* @memberOf _
* @category Object
diff --git a/some.js b/some.js
index 122ceb162..da97a5a8f 100644
--- a/some.js
+++ b/some.js
@@ -26,15 +26,15 @@ import isIterateeCall from './_isIterateeCall';
* { 'user': 'fred', 'active': false }
* ];
*
- * // using the `_.matches` iteratee shorthand
+ * // The `_.matches` iteratee shorthand.
* _.some(users, { 'user': 'barney', 'active': false });
* // => false
*
- * // using the `_.matchesProperty` iteratee shorthand
+ * // The `_.matchesProperty` iteratee shorthand.
* _.some(users, ['active', false]);
* // => true
*
- * // using the `_.property` iteratee shorthand
+ * // The `_.property` iteratee shorthand.
* _.some(users, 'active');
* // => true
*/
diff --git a/sortedIndexBy.js b/sortedIndexBy.js
index 9a44fc10b..91e05e980 100644
--- a/sortedIndexBy.js
+++ b/sortedIndexBy.js
@@ -20,7 +20,7 @@ import baseSortedIndexBy from './_baseSortedIndexBy';
* _.sortedIndexBy(['thirty', 'fifty'], 'forty', _.propertyOf(dict));
* // => 1
*
- * // using the `_.property` iteratee shorthand
+ * // The `_.property` iteratee shorthand.
* _.sortedIndexBy([{ 'x': 4 }, { 'x': 5 }], { 'x': 4 }, 'x');
* // => 0
*/
diff --git a/sortedLastIndexBy.js b/sortedLastIndexBy.js
index 8f4a20ded..331cfcae8 100644
--- a/sortedLastIndexBy.js
+++ b/sortedLastIndexBy.js
@@ -15,7 +15,7 @@ import baseSortedIndexBy from './_baseSortedIndexBy';
* @returns {number} Returns the index at which `value` should be inserted into `array`.
* @example
*
- * // using the `_.property` iteratee shorthand
+ * // The `_.property` iteratee shorthand.
* _.sortedLastIndexBy([{ 'x': 4 }, { 'x': 5 }], { 'x': 4 }, 'x');
* // => 1
*/
diff --git a/sortedUniqBy.js b/sortedUniqBy.js
index fa095e2ff..1a85bba14 100644
--- a/sortedUniqBy.js
+++ b/sortedUniqBy.js
@@ -14,7 +14,7 @@ import baseSortedUniqBy from './_baseSortedUniqBy';
* @example
*
* _.sortedUniqBy([1.1, 1.2, 2.3, 2.4], Math.floor);
- * // => [1.1, 2.2]
+ * // => [1.1, 2.3]
*/
function sortedUniqBy(array, iteratee) {
return (array && array.length)
diff --git a/spread.js b/spread.js
index 12a4de9e1..5dd8fe606 100644
--- a/spread.js
+++ b/spread.js
@@ -1,8 +1,14 @@
import apply from './_apply';
+import arrayPush from './_arrayPush';
+import rest from './rest';
+import toInteger from './toInteger';
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeMax = Math.max;
+
/**
* Creates a function that invokes `func` with the `this` binding of the created
* function and an array of arguments much like [`Function#apply`](https://es5.github.io/#x15.3.4.3).
@@ -13,6 +19,7 @@ var FUNC_ERROR_TEXT = 'Expected a function';
* @memberOf _
* @category Function
* @param {Function} func The function to spread arguments over.
+ * @param {number} [start=0] The start position of the spread.
* @returns {Function} Returns the new function.
* @example
*
@@ -23,7 +30,6 @@ var FUNC_ERROR_TEXT = 'Expected a function';
* say(['fred', 'hello']);
* // => 'fred says hello'
*
- * // with a Promise
* var numbers = Promise.all([
* Promise.resolve(40),
* Promise.resolve(36)
@@ -34,13 +40,20 @@ var FUNC_ERROR_TEXT = 'Expected a function';
* }));
* // => a Promise of 76
*/
-function spread(func) {
+function spread(func, start) {
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
- return function(array) {
- return apply(func, this, array);
- };
+ start = start === undefined ? 0 : nativeMax(toInteger(start), 0);
+ return rest(function(args) {
+ var array = args[start],
+ otherArgs = args.slice(0, start);
+
+ if (array) {
+ arrayPush(otherArgs, array);
+ }
+ return apply(func, this, otherArgs);
+ });
}
export default spread;
diff --git a/sumBy.js b/sumBy.js
index 9faa08e52..276c0b591 100644
--- a/sumBy.js
+++ b/sumBy.js
@@ -19,7 +19,7 @@ import baseSum from './_baseSum';
* _.sumBy(objects, function(o) { return o.n; });
* // => 20
*
- * // using the `_.property` iteratee shorthand
+ * // The `_.property` iteratee shorthand.
* _.sumBy(objects, 'n');
* // => 20
*/
diff --git a/takeRightWhile.js b/takeRightWhile.js
index e485cc0d4..c619cb930 100644
--- a/takeRightWhile.js
+++ b/takeRightWhile.js
@@ -23,15 +23,15 @@ import baseWhile from './_baseWhile';
* _.takeRightWhile(users, function(o) { return !o.active; });
* // => objects for ['fred', 'pebbles']
*
- * // using the `_.matches` iteratee shorthand
+ * // The `_.matches` iteratee shorthand.
* _.takeRightWhile(users, { 'user': 'pebbles', 'active': false });
* // => objects for ['pebbles']
*
- * // using the `_.matchesProperty` iteratee shorthand
+ * // The `_.matchesProperty` iteratee shorthand.
* _.takeRightWhile(users, ['active', false]);
* // => objects for ['fred', 'pebbles']
*
- * // using the `_.property` iteratee shorthand
+ * // The `_.property` iteratee shorthand.
* _.takeRightWhile(users, 'active');
* // => []
*/
diff --git a/takeWhile.js b/takeWhile.js
index 88de89b67..f14502159 100644
--- a/takeWhile.js
+++ b/takeWhile.js
@@ -23,15 +23,15 @@ import baseWhile from './_baseWhile';
* _.takeWhile(users, function(o) { return !o.active; });
* // => objects for ['barney', 'fred']
*
- * // using the `_.matches` iteratee shorthand
+ * // The `_.matches` iteratee shorthand.
* _.takeWhile(users, { 'user': 'barney', 'active': false });
* // => objects for ['barney']
*
- * // using the `_.matchesProperty` iteratee shorthand
+ * // The `_.matchesProperty` iteratee shorthand.
* _.takeWhile(users, ['active', false]);
* // => objects for ['barney', 'fred']
*
- * // using the `_.property` iteratee shorthand
+ * // The `_.property` iteratee shorthand.
* _.takeWhile(users, 'active');
* // => []
*/
diff --git a/tap.js b/tap.js
index 0a31e59d5..645b28905 100644
--- a/tap.js
+++ b/tap.js
@@ -1,8 +1,7 @@
/**
- * This method invokes `interceptor` and returns `value`. The interceptor is
- * invoked with one argument; (value). The purpose of this method is to "tap into"
- * a method chain in order to perform operations on intermediate results within
- * the chain.
+ * This method invokes `interceptor` and returns `value`. The interceptor
+ * is invoked with one argument; (value). The purpose of this method is to
+ * "tap into" a method chain in order to modify intermediate results.
*
* @static
* @memberOf _
@@ -14,6 +13,7 @@
*
* _([1, 2, 3])
* .tap(function(array) {
+ * // Mutate input array.
* array.pop();
* })
* .reverse()
diff --git a/template.js b/template.js
index c8bf402f7..a15aeb21e 100644
--- a/template.js
+++ b/template.js
@@ -56,54 +56,54 @@ var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
* @returns {Function} Returns the compiled template function.
* @example
*
- * // using the "interpolate" delimiter to create a compiled template
+ * // Use the "interpolate" delimiter to create a compiled template.
* var compiled = _.template('hello <%= user %>!');
* compiled({ 'user': 'fred' });
* // => 'hello fred!'
*
- * // using the HTML "escape" delimiter to escape data property values
+ * // Use the HTML "escape" delimiter to escape data property values.
* var compiled = _.template('<%- value %>');
* compiled({ 'value': '