diff --git a/README.md b/README.md
index e8e2de24b..2a589a5f2 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# lodash-es v4.10.0
+# lodash-es v4.11.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.10.0-es) for more details.
+See the [package source](https://github.com/lodash/lodash/tree/4.11.0-es) for more details.
diff --git a/_baseNth.js b/_baseNth.js
new file mode 100644
index 000000000..31d0b880f
--- /dev/null
+++ b/_baseNth.js
@@ -0,0 +1,20 @@
+import isIndex from './_isIndex';
+
+/**
+ * The base implementation of `_.nth` which doesn't coerce `n` to an integer.
+ *
+ * @private
+ * @param {Array} array The array to query.
+ * @param {number} n The index of the element to return.
+ * @returns {*} Returns the nth element of `array`.
+ */
+function baseNth(array, n) {
+ var length = array.length;
+ if (!length) {
+ return;
+ }
+ n += n < 0 ? length : 0;
+ return isIndex(n, length) ? array[n] : undefined;
+}
+
+export default baseNth;
diff --git a/_baseOrderBy.js b/_baseOrderBy.js
index 4a200e570..9a71e53f9 100644
--- a/_baseOrderBy.js
+++ b/_baseOrderBy.js
@@ -2,6 +2,7 @@ import arrayMap from './_arrayMap';
import baseIteratee from './_baseIteratee';
import baseMap from './_baseMap';
import baseSortBy from './_baseSortBy';
+import baseUnary from './_baseUnary';
import compareMultiple from './_compareMultiple';
import identity from './identity';
@@ -16,7 +17,7 @@ import identity from './identity';
*/
function baseOrderBy(collection, iteratees, orders) {
var index = -1;
- iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseIteratee);
+ iteratees = arrayMap(iteratees.length ? iteratees : [identity], baseUnary(baseIteratee));
var result = baseMap(collection, function(value, key, collection) {
var criteria = arrayMap(iteratees, function(iteratee) {
diff --git a/_copyObject.js b/_copyObject.js
index 4028fc0bd..054a603e4 100644
--- a/_copyObject.js
+++ b/_copyObject.js
@@ -1,4 +1,4 @@
-import copyObjectWith from './_copyObjectWith';
+import assignValue from './_assignValue';
/**
* Copies properties of `source` to `object`.
@@ -7,10 +7,25 @@ import copyObjectWith from './_copyObjectWith';
* @param {Object} source The object to copy properties from.
* @param {Array} props The property identifiers to copy.
* @param {Object} [object={}] The object to copy properties to.
+ * @param {Function} [customizer] The function to customize copied values.
* @returns {Object} Returns `object`.
*/
-function copyObject(source, props, object) {
- return copyObjectWith(source, props, object);
+function copyObject(source, props, object, customizer) {
+ object || (object = {});
+
+ var index = -1,
+ length = props.length;
+
+ while (++index < length) {
+ var key = props[index];
+
+ var newValue = customizer
+ ? customizer(object[key], source[key], key, object, source)
+ : source[key];
+
+ assignValue(object, key, newValue);
+ }
+ return object;
}
export default copyObject;
diff --git a/_copyObjectWith.js b/_copyObjectWith.js
deleted file mode 100644
index 76d8d6af5..000000000
--- a/_copyObjectWith.js
+++ /dev/null
@@ -1,32 +0,0 @@
-import assignValue from './_assignValue';
-
-/**
- * This function is like `copyObject` except that it accepts a function to
- * customize copied values.
- *
- * @private
- * @param {Object} source The object to copy properties from.
- * @param {Array} props The property identifiers to copy.
- * @param {Object} [object={}] The object to copy properties to.
- * @param {Function} [customizer] The function to customize copied values.
- * @returns {Object} Returns `object`.
- */
-function copyObjectWith(source, props, object, customizer) {
- object || (object = {});
-
- var index = -1,
- length = props.length;
-
- while (++index < length) {
- var key = props[index];
-
- var newValue = customizer
- ? customizer(object[key], source[key], key, object, source)
- : source[key];
-
- assignValue(object, key, newValue);
- }
- return object;
-}
-
-export default copyObjectWith;
diff --git a/_createCompounder.js b/_createCompounder.js
index 69e511fa5..818912f4f 100644
--- a/_createCompounder.js
+++ b/_createCompounder.js
@@ -2,6 +2,12 @@ import arrayReduce from './_arrayReduce';
import deburr from './deburr';
import words from './words';
+/** Used to compose unicode capture groups. */
+var rsApos = "['\u2019]";
+
+/** Used to match apostrophes. */
+var reApos = RegExp(rsApos, 'g');
+
/**
* Creates a function like `_.camelCase`.
*
@@ -11,7 +17,7 @@ import words from './words';
*/
function createCompounder(callback) {
return function(string) {
- return arrayReduce(words(deburr(string)), callback, '');
+ return arrayReduce(words(deburr(string).replace(reApos, '')), callback, '');
};
}
diff --git a/_createOver.js b/_createOver.js
index c972d4696..1f4093d9e 100644
--- a/_createOver.js
+++ b/_createOver.js
@@ -2,6 +2,8 @@ import apply from './_apply';
import arrayMap from './_arrayMap';
import baseFlatten from './_baseFlatten';
import baseIteratee from './_baseIteratee';
+import baseUnary from './_baseUnary';
+import isArray from './isArray';
import isFlattenableIteratee from './_isFlattenableIteratee';
import rest from './rest';
@@ -14,7 +16,10 @@ import rest from './rest';
*/
function createOver(arrayFunc) {
return rest(function(iteratees) {
- iteratees = arrayMap(baseFlatten(iteratees, 1, isFlattenableIteratee), baseIteratee);
+ iteratees = (iteratees.length == 1 && isArray(iteratees[0]))
+ ? arrayMap(iteratees[0], baseUnary(baseIteratee))
+ : arrayMap(baseFlatten(iteratees, 1, isFlattenableIteratee), baseUnary(baseIteratee));
+
return rest(function(args) {
var thisArg = this;
return arrayFunc(iteratees, function(iteratee) {
diff --git a/_createRecurryWrapper.js b/_createRecurryWrapper.js
index 94a71bd75..6df8c24f6 100644
--- a/_createRecurryWrapper.js
+++ b/_createRecurryWrapper.js
@@ -1,4 +1,3 @@
-import copyArray from './_copyArray';
import isLaziable from './_isLaziable';
import setData from './_setData';
@@ -30,7 +29,6 @@ var BIND_FLAG = 1,
*/
function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
var isCurry = bitmask & CURRY_FLAG,
- newArgPos = argPos ? copyArray(argPos) : undefined,
newHolders = isCurry ? holders : undefined,
newHoldersRight = isCurry ? undefined : holders,
newPartials = isCurry ? partials : undefined,
@@ -44,7 +42,7 @@ function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, par
}
var newData = [
func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
- newHoldersRight, newArgPos, ary, arity
+ newHoldersRight, argPos, ary, arity
];
var result = wrapFunc.apply(undefined, newData);
diff --git a/_mergeData.js b/_mergeData.js
index 6e230a4af..1b0b4d6a6 100644
--- a/_mergeData.js
+++ b/_mergeData.js
@@ -1,6 +1,5 @@
import composeArgs from './_composeArgs';
import composeArgsRight from './_composeArgsRight';
-import copyArray from './_copyArray';
import replaceHolders from './_replaceHolders';
/** Used as the internal argument placeholder. */
@@ -58,20 +57,20 @@ function mergeData(data, source) {
var value = source[3];
if (value) {
var partials = data[3];
- data[3] = partials ? composeArgs(partials, value, source[4]) : copyArray(value);
- data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : copyArray(source[4]);
+ data[3] = partials ? composeArgs(partials, value, source[4]) : value;
+ data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
}
// Compose partial right arguments.
value = source[5];
if (value) {
partials = data[5];
- data[5] = partials ? composeArgsRight(partials, value, source[6]) : copyArray(value);
- data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : copyArray(source[6]);
+ data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
+ data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
}
// Use source `argPos` if available.
value = source[7];
if (value) {
- data[7] = copyArray(value);
+ data[7] = value;
}
// Use source `ary` if it's smaller.
if (srcBitmask & ARY_FLAG) {
diff --git a/array.default.js b/array.default.js
index 608789c53..316fd15a4 100644
--- a/array.default.js
+++ b/array.default.js
@@ -24,6 +24,7 @@ import intersectionWith from './intersectionWith';
import join from './join';
import last from './last';
import lastIndexOf from './lastIndexOf';
+import nth from './nth';
import pull from './pull';
import pullAll from './pullAll';
import pullAllBy from './pullAllBy';
@@ -68,12 +69,12 @@ export default {
fill, findIndex, findLastIndex, flatten, flattenDeep,
flattenDepth, fromPairs, head, indexOf, initial,
intersection, intersectionBy, intersectionWith, join, last,
- lastIndexOf, pull, pullAll, pullAllBy, pullAllWith,
- 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
+ lastIndexOf, nth, pull, pullAll, pullAllBy,
+ pullAllWith, 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 753314615..5aee782e5 100644
--- a/array.js
+++ b/array.js
@@ -24,6 +24,7 @@ export { default as intersectionWith } from './intersectionWith';
export { default as join } from './join';
export { default as last } from './last';
export { default as lastIndexOf } from './lastIndexOf';
+export { default as nth } from './nth';
export { default as pull } from './pull';
export { default as pullAll } from './pullAll';
export { default as pullAllBy } from './pullAllBy';
diff --git a/assignInWith.js b/assignInWith.js
index 7f2aa2755..0c4f971d7 100644
--- a/assignInWith.js
+++ b/assignInWith.js
@@ -1,4 +1,4 @@
-import copyObjectWith from './_copyObjectWith';
+import copyObject from './_copyObject';
import createAssigner from './_createAssigner';
import keysIn from './keysIn';
@@ -31,7 +31,7 @@ import keysIn from './keysIn';
* // => { 'a': 1, 'b': 2 }
*/
var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
- copyObjectWith(source, keysIn(source), object, customizer);
+ copyObject(source, keysIn(source), object, customizer);
});
export default assignInWith;
diff --git a/assignWith.js b/assignWith.js
index 0b8bfe124..8b6396d0c 100644
--- a/assignWith.js
+++ b/assignWith.js
@@ -1,4 +1,4 @@
-import copyObjectWith from './_copyObjectWith';
+import copyObject from './_copyObject';
import createAssigner from './_createAssigner';
import keys from './keys';
@@ -30,7 +30,7 @@ import keys from './keys';
* // => { 'a': 1, 'b': 2 }
*/
var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
- copyObjectWith(source, keys(source), object, customizer);
+ copyObject(source, keys(source), object, customizer);
});
export default assignWith;
diff --git a/head.js b/head.js
index b6e16f95f..0a62691c3 100644
--- a/head.js
+++ b/head.js
@@ -17,7 +17,7 @@
* // => undefined
*/
function head(array) {
- return array ? array[0] : undefined;
+ return (array && array.length) ? array[0] : undefined;
}
export default head;
diff --git a/lodash.default.js b/lodash.default.js
index 604e265e0..c950b63fc 100644
--- a/lodash.default.js
+++ b/lodash.default.js
@@ -1,6 +1,6 @@
/**
* @license
- * lodash 4.10.0 (Custom Build)
+ * lodash 4.11.0 (Custom Build)
* Build: `lodash modularize exports="es" -o ./`
* Copyright jQuery Foundation and other contributors
* Released under MIT license
@@ -44,7 +44,7 @@ import toInteger from './toInteger';
import lodash from './wrapperLodash';
/** Used as the semantic version number. */
-var VERSION = '4.10.0';
+var VERSION = '4.11.0';
/** Used to compose bitmasks for wrapper metadata. */
var BIND_KEY_FLAG = 2;
@@ -342,6 +342,7 @@ lodash.meanBy = math.meanBy;
lodash.min = math.min;
lodash.minBy = math.minBy;
lodash.multiply = math.multiply;
+lodash.nth = array.nth;
lodash.noop = util.noop;
lodash.now = date.now;
lodash.pad = string.pad;
diff --git a/lodash.js b/lodash.js
index 618aa60ab..f63008d36 100644
--- a/lodash.js
+++ b/lodash.js
@@ -1,6 +1,6 @@
/**
* @license
- * lodash 4.10.0 (Custom Build)
+ * lodash 4.11.0 (Custom Build)
* Build: `lodash modularize exports="es" -o ./`
* Copyright jQuery Foundation and other contributors
* Released under MIT license
@@ -184,6 +184,7 @@ export { default as negate } from './negate';
export { default as next } from './next';
export { default as noop } from './noop';
export { default as now } from './now';
+export { default as nth } from './nth';
export { default as nthArg } from './nthArg';
export { default as omit } from './omit';
export { default as omitBy } from './omitBy';
diff --git a/nth.js b/nth.js
new file mode 100644
index 000000000..910e0a292
--- /dev/null
+++ b/nth.js
@@ -0,0 +1,29 @@
+import baseNth from './_baseNth';
+import toInteger from './toInteger';
+
+/**
+ * Gets the nth element of `array`. If `n` is negative, the nth element
+ * from the end is returned.
+ *
+ * @static
+ * @memberOf _
+ * @since 4.11.0
+ * @category Array
+ * @param {Array} array The array to query.
+ * @param {number} [n=0] The index of the element to return.
+ * @returns {*} Returns the nth element of `array`.
+ * @example
+ *
+ * var array = ['a', 'b', 'c', 'd'];
+ *
+ * _.nth(array, 1);
+ * // => 'b'
+ *
+ * _.nth(array, -2);
+ * // => 'c';
+ */
+function nth(array, n) {
+ return (array && array.length) ? baseNth(array, toInteger(n)) : undefined;
+}
+
+export default nth;
diff --git a/nthArg.js b/nthArg.js
index d1c4e7381..29bbe7fd4 100644
--- a/nthArg.js
+++ b/nthArg.js
@@ -1,7 +1,10 @@
+import baseNth from './_baseNth';
+import rest from './rest';
import toInteger from './toInteger';
/**
- * Creates a function that returns its nth argument.
+ * Creates a function that returns its nth argument. If `n` is negative,
+ * the nth argument from the end is returned.
*
* @static
* @memberOf _
@@ -12,15 +15,18 @@ import toInteger from './toInteger';
* @example
*
* var func = _.nthArg(1);
- *
- * func('a', 'b', 'c');
+ * func('a', 'b', 'c', 'd');
* // => 'b'
+ *
+ * var func = _.nthArg(-2);
+ * func('a', 'b', 'c', 'd');
+ * // => 'c'
*/
function nthArg(n) {
n = toInteger(n);
- return function() {
- return arguments[n];
- };
+ return rest(function(args) {
+ return baseNth(args, n);
+ });
}
export default nthArg;
diff --git a/overArgs.js b/overArgs.js
index 1e33d0279..51b5b29db 100644
--- a/overArgs.js
+++ b/overArgs.js
@@ -2,6 +2,8 @@ import apply from './_apply';
import arrayMap from './_arrayMap';
import baseFlatten from './_baseFlatten';
import baseIteratee from './_baseIteratee';
+import baseUnary from './_baseUnary';
+import isArray from './isArray';
import isFlattenableIteratee from './_isFlattenableIteratee';
import rest from './rest';
@@ -41,7 +43,10 @@ var nativeMin = Math.min;
* // => [100, 10]
*/
var overArgs = rest(function(func, transforms) {
- transforms = arrayMap(baseFlatten(transforms, 1, isFlattenableIteratee), baseIteratee);
+ transforms = (transforms.length == 1 && isArray(transforms[0]))
+ ? arrayMap(transforms[0], baseUnary(baseIteratee))
+ : arrayMap(baseFlatten(transforms, 1, isFlattenableIteratee), baseUnary(baseIteratee));
+
var funcsLength = transforms.length;
return rest(function(args) {
var index = -1,
diff --git a/package.json b/package.json
index 95f3bf0e7..07eacb0bf 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "lodash-es",
- "version": "4.10.0",
+ "version": "4.11.0",
"description": "Lodash exported as ES modules.",
"homepage": "https://lodash.com/custom-builds",
"license": "MIT",
diff --git a/replace.js b/replace.js
index 5613c9ceb..e6d4d72f4 100644
--- a/replace.js
+++ b/replace.js
@@ -1,5 +1,11 @@
import toString from './toString';
+/** Used for built-in method references. */
+var stringProto = String.prototype;
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeReplace = stringProto.replace;
+
/**
* Replaces matches for `pattern` in `string` with `replacement`.
*
@@ -23,7 +29,7 @@ function replace() {
var args = arguments,
string = toString(args[0]);
- return args.length < 3 ? string : string.replace(args[1], args[2]);
+ return args.length < 3 ? string : nativeReplace.call(string, args[1], args[2]);
}
export default replace;
diff --git a/sortBy.js b/sortBy.js
index 9fe3665bc..bd0d132e0 100644
--- a/sortBy.js
+++ b/sortBy.js
@@ -1,5 +1,7 @@
import baseFlatten from './_baseFlatten';
import baseOrderBy from './_baseOrderBy';
+import isArray from './isArray';
+import isFlattenableIteratee from './_isFlattenableIteratee';
import isIterateeCall from './_isIterateeCall';
import rest from './rest';
@@ -47,7 +49,11 @@ var sortBy = rest(function(collection, iteratees) {
} else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
iteratees = [iteratees[0]];
}
- return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
+ iteratees = (iteratees.length == 1 && isArray(iteratees[0]))
+ ? iteratees[0]
+ : baseFlatten(iteratees, 1, isFlattenableIteratee);
+
+ return baseOrderBy(collection, iteratees, []);
});
export default sortBy;
diff --git a/split.js b/split.js
index 2452e01b2..8d98d4053 100644
--- a/split.js
+++ b/split.js
@@ -8,6 +8,12 @@ import toString from './toString';
/** Used as references for the maximum length and index of an array. */
var MAX_ARRAY_LENGTH = 4294967295;
+/** Used for built-in method references. */
+var stringProto = String.prototype;
+
+/* Built-in method references for those with the same name as other `lodash` methods. */
+var nativeSplit = stringProto.split;
+
/**
* Splits `string` by `separator`.
*
@@ -45,7 +51,7 @@ function split(string, separator, limit) {
return castSlice(stringToArray(string), 0, limit);
}
}
- return string.split(separator, limit);
+ return nativeSplit.call(string, separator, limit);
}
export default split;
diff --git a/words.js b/words.js
index 27ce8391f..e5febb7dc 100644
--- a/words.js
+++ b/words.js
@@ -18,7 +18,8 @@ var rsAstralRange = '\\ud800-\\udfff',
rsBreakRange = rsMathOpRange + rsNonCharRange + rsQuoteRange + rsSpaceRange;
/** Used to compose unicode capture groups. */
-var rsBreak = '[' + rsBreakRange + ']',
+var rsApos = "['\u2019]",
+ rsBreak = '[' + rsBreakRange + ']',
rsCombo = '[' + rsComboMarksRange + rsComboSymbolsRange + ']',
rsDigits = '\\d+',
rsDingbat = '[' + rsDingbatRange + ']',
@@ -35,6 +36,8 @@ var rsBreak = '[' + rsBreakRange + ']',
/** Used to compose unicode regexes. */
var rsLowerMisc = '(?:' + rsLower + '|' + rsMisc + ')',
rsUpperMisc = '(?:' + rsUpper + '|' + rsMisc + ')',
+ rsOptLowerContr = '(?:' + rsApos + '(?:d|ll|m|re|s|t|ve))?',
+ rsOptUpperContr = '(?:' + rsApos + '(?:D|LL|M|RE|S|T|VE))?',
reOptMod = rsModifier + '?',
rsOptVar = '[' + rsVarRange + ']?',
rsOptJoin = '(?:' + rsZWJ + '(?:' + [rsNonAstral, rsRegional, rsSurrPair].join('|') + ')' + rsOptVar + reOptMod + ')*',
@@ -43,10 +46,10 @@ var rsLowerMisc = '(?:' + rsLower + '|' + rsMisc + ')',
/** Used to match complex or compound words. */
var reComplexWord = RegExp([
- rsUpper + '?' + rsLower + '+(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
- rsUpperMisc + '+(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')',
- rsUpper + '?' + rsLowerMisc + '+',
- rsUpper + '+',
+ rsUpper + '?' + rsLower + '+' + rsOptLowerContr + '(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
+ rsUpperMisc + '+' + rsOptUpperContr + '(?=' + [rsBreak, rsUpper + rsLowerMisc, '$'].join('|') + ')',
+ rsUpper + '?' + rsLowerMisc + '+' + rsOptLowerContr,
+ rsUpper + '+' + rsOptUpperContr,
rsDigits,
rsEmoji
].join('|'), 'g');
diff --git a/wrapperLodash.js b/wrapperLodash.js
index c5ebfbff5..f45f42894 100644
--- a/wrapperLodash.js
+++ b/wrapperLodash.js
@@ -91,7 +91,7 @@ var hasOwnProperty = objectProto.hasOwnProperty;
* `isSet`, `isString`, `isUndefined`, `isTypedArray`, `isWeakMap`, `isWeakSet`,
* `join`, `kebabCase`, `last`, `lastIndexOf`, `lowerCase`, `lowerFirst`,
* `lt`, `lte`, `max`, `maxBy`, `mean`, `meanBy`, `min`, `minBy`, `multiply`,
- * `noConflict`, `noop`, `now`, `pad`, `padEnd`, `padStart`, `parseInt`,
+ * `noConflict`, `noop`, `now`, `nth`, `pad`, `padEnd`, `padStart`, `parseInt`,
* `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, `round`,
* `runInContext`, `sample`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`,
* `sortedIndexBy`, `sortedLastIndex`, `sortedLastIndexBy`, `startCase`,