diff --git a/README.md b/README.md
index 372d2e0f0..fc373770c 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# lodash-amd v4.9.0
+# lodash-amd v4.10.0
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.9.0-amd) for more details.
+See the [package source](https://github.com/lodash/lodash/tree/4.10.0-amd) for more details.
diff --git a/_baseFor.js b/_baseFor.js
index 64b1f4d85..e58964891 100644
--- a/_baseFor.js
+++ b/_baseFor.js
@@ -2,7 +2,7 @@ define(['./_createBaseFor'], function(createBaseFor) {
/**
* The base implementation of `baseForOwn` which iterates over `object`
- * properties returned by `keysFunc` invoking `iteratee` for each property.
+ * properties returned by `keysFunc` and invokes `iteratee` for each property.
* Iteratee functions may exit iteration early by explicitly returning `false`.
*
* @private
diff --git a/_baseGet.js b/_baseGet.js
index eb0f1a303..3ca58cb4f 100644
--- a/_baseGet.js
+++ b/_baseGet.js
@@ -1,4 +1,4 @@
-define(['./_baseCastPath', './_isKey'], function(baseCastPath, isKey) {
+define(['./_castPath', './_isKey'], function(castPath, isKey) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -12,7 +12,7 @@ define(['./_baseCastPath', './_isKey'], function(baseCastPath, isKey) {
* @returns {*} Returns the resolved value.
*/
function baseGet(object, path) {
- path = isKey(path, object) ? [path] : baseCastPath(path);
+ path = isKey(path, object) ? [path] : castPath(path);
var index = 0,
length = path.length;
diff --git a/_baseInvoke.js b/_baseInvoke.js
index 0869f868e..64455126f 100644
--- a/_baseInvoke.js
+++ b/_baseInvoke.js
@@ -1,4 +1,4 @@
-define(['./_apply', './_baseCastPath', './_isKey', './last', './_parent'], function(apply, baseCastPath, isKey, last, parent) {
+define(['./_apply', './_castPath', './_isKey', './last', './_parent'], function(apply, castPath, isKey, last, parent) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -15,7 +15,7 @@ define(['./_apply', './_baseCastPath', './_isKey', './last', './_parent'], funct
*/
function baseInvoke(object, path, args) {
if (!isKey(path, object)) {
- path = baseCastPath(path);
+ path = castPath(path);
object = parent(object, path);
path = last(path);
}
diff --git a/_basePullAt.js b/_basePullAt.js
index 4475a6d0e..cf0f5d924 100644
--- a/_basePullAt.js
+++ b/_basePullAt.js
@@ -1,4 +1,4 @@
-define(['./_baseCastPath', './_isIndex', './_isKey', './last', './_parent'], function(baseCastPath, isIndex, isKey, last, parent) {
+define(['./_castPath', './_isIndex', './_isKey', './last', './_parent'], function(castPath, isIndex, isKey, last, parent) {
/** Used for built-in method references. */
var arrayProto = Array.prototype;
@@ -27,7 +27,7 @@ define(['./_baseCastPath', './_isIndex', './_isKey', './last', './_parent'], fun
splice.call(array, index, 1);
}
else if (!isKey(index, array)) {
- var path = baseCastPath(index),
+ var path = castPath(index),
object = parent(array, path);
if (object != null) {
diff --git a/_baseSet.js b/_baseSet.js
index 5d2d83579..e5c4d6328 100644
--- a/_baseSet.js
+++ b/_baseSet.js
@@ -1,4 +1,4 @@
-define(['./_assignValue', './_baseCastPath', './_isIndex', './_isKey', './isObject'], function(assignValue, baseCastPath, isIndex, isKey, isObject) {
+define(['./_assignValue', './_castPath', './_isIndex', './_isKey', './isObject'], function(assignValue, castPath, isIndex, isKey, isObject) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -14,7 +14,7 @@ define(['./_assignValue', './_baseCastPath', './_isIndex', './_isKey', './isObje
* @returns {Object} Returns `object`.
*/
function baseSet(object, path, value, customizer) {
- path = isKey(path, object) ? [path] : baseCastPath(path);
+ path = isKey(path, object) ? [path] : castPath(path);
var index = -1,
length = path.length,
diff --git a/_baseUnset.js b/_baseUnset.js
index ed96fe1d7..c819af7b6 100644
--- a/_baseUnset.js
+++ b/_baseUnset.js
@@ -1,4 +1,4 @@
-define(['./_baseCastPath', './has', './_isKey', './last', './_parent'], function(baseCastPath, has, isKey, last, parent) {
+define(['./_castPath', './has', './_isKey', './last', './_parent'], function(castPath, has, isKey, last, parent) {
/**
* The base implementation of `_.unset`.
@@ -9,7 +9,7 @@ define(['./_baseCastPath', './has', './_isKey', './last', './_parent'], function
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
*/
function baseUnset(object, path) {
- path = isKey(path, object) ? [path] : baseCastPath(path);
+ path = isKey(path, object) ? [path] : castPath(path);
object = parent(object, path);
var key = last(path);
return (object != null && has(object, key)) ? delete object[key] : true;
diff --git a/_baseCastArrayLikeObject.js b/_castArrayLikeObject.js
similarity index 81%
rename from _baseCastArrayLikeObject.js
rename to _castArrayLikeObject.js
index 83693ddda..d9037d9f3 100644
--- a/_baseCastArrayLikeObject.js
+++ b/_castArrayLikeObject.js
@@ -7,9 +7,9 @@ define(['./isArrayLikeObject'], function(isArrayLikeObject) {
* @param {*} value The value to inspect.
* @returns {Array|Object} Returns the cast array-like object.
*/
- function baseCastArrayLikeObject(value) {
+ function castArrayLikeObject(value) {
return isArrayLikeObject(value) ? value : [];
}
- return baseCastArrayLikeObject;
+ return castArrayLikeObject;
});
diff --git a/_baseCastFunction.js b/_castFunction.js
similarity index 82%
rename from _baseCastFunction.js
rename to _castFunction.js
index 3cf65a37d..b116f0526 100644
--- a/_baseCastFunction.js
+++ b/_castFunction.js
@@ -7,9 +7,9 @@ define(['./identity'], function(identity) {
* @param {*} value The value to inspect.
* @returns {Function} Returns cast function.
*/
- function baseCastFunction(value) {
+ function castFunction(value) {
return typeof value == 'function' ? value : identity;
}
- return baseCastFunction;
+ return castFunction;
});
diff --git a/_baseCastPath.js b/_castPath.js
similarity index 85%
rename from _baseCastPath.js
rename to _castPath.js
index b15bf14e8..17e4a5888 100644
--- a/_baseCastPath.js
+++ b/_castPath.js
@@ -7,9 +7,9 @@ define(['./isArray', './_stringToPath'], function(isArray, stringToPath) {
* @param {*} value The value to inspect.
* @returns {Array} Returns the cast property path array.
*/
- function baseCastPath(value) {
+ function castPath(value) {
return isArray(value) ? value : stringToPath(value);
}
- return baseCastPath;
+ return castPath;
});
diff --git a/_castSlice.js b/_castSlice.js
new file mode 100644
index 000000000..978231c98
--- /dev/null
+++ b/_castSlice.js
@@ -0,0 +1,22 @@
+define(['./_baseSlice'], function(baseSlice) {
+
+ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
+ var undefined;
+
+ /**
+ * Casts `array` to a slice if it's needed.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {number} start The start position.
+ * @param {number} [end=array.length] The end position.
+ * @returns {Array} Returns the cast slice.
+ */
+ function castSlice(array, start, end) {
+ var length = array.length;
+ end = end === undefined ? length : end;
+ return (!start && end >= length) ? array : baseSlice(array, start, end);
+ }
+
+ return castSlice;
+});
diff --git a/_createCaseFirst.js b/_createCaseFirst.js
index af5f546e8..2f60a0e32 100644
--- a/_createCaseFirst.js
+++ b/_createCaseFirst.js
@@ -1,20 +1,8 @@
-define(['./_stringToArray', './toString'], function(stringToArray, toString) {
+define(['./_castSlice', './_reHasComplexSymbol', './_stringToArray', './toString'], function(castSlice, reHasComplexSymbol, stringToArray, toString) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
- /** Used to compose unicode character classes. */
- var rsAstralRange = '\\ud800-\\udfff',
- 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 + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
-
/**
* Creates a function like `_.lowerFirst`.
*
@@ -30,8 +18,13 @@ define(['./_stringToArray', './toString'], function(stringToArray, toString) {
? stringToArray(string)
: undefined;
- var chr = strSymbols ? strSymbols[0] : string.charAt(0),
- trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1);
+ var chr = strSymbols
+ ? strSymbols[0]
+ : string.charAt(0);
+
+ var trailing = strSymbols
+ ? castSlice(strSymbols, 1).join('')
+ : string.slice(1);
return chr[methodName]() + trailing;
};
diff --git a/_createPadding.js b/_createPadding.js
index fcd788422..75acb8c52 100644
--- a/_createPadding.js
+++ b/_createPadding.js
@@ -1,20 +1,8 @@
-define(['./_baseRepeat', './_stringSize', './_stringToArray'], function(baseRepeat, stringSize, stringToArray) {
+define(['./_baseRepeat', './_castSlice', './_reHasComplexSymbol', './_stringSize', './_stringToArray'], function(baseRepeat, castSlice, reHasComplexSymbol, stringSize, stringToArray) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
- /** Used to compose unicode character classes. */
- var rsAstralRange = '\\ud800-\\udfff',
- 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 + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
-
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeCeil = Math.ceil;
@@ -36,7 +24,7 @@ define(['./_baseRepeat', './_stringSize', './_stringToArray'], function(baseRepe
}
var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
return reHasComplexSymbol.test(chars)
- ? stringToArray(result).slice(0, length).join('')
+ ? castSlice(stringToArray(result), 0, length).join('')
: result.slice(0, length);
}
diff --git a/_hasPath.js b/_hasPath.js
index 4427d41e0..f9f6a87c2 100644
--- a/_hasPath.js
+++ b/_hasPath.js
@@ -1,4 +1,4 @@
-define(['./_baseCastPath', './isArguments', './isArray', './_isIndex', './_isKey', './isLength', './isString'], function(baseCastPath, isArguments, isArray, isIndex, isKey, isLength, isString) {
+define(['./_castPath', './isArguments', './isArray', './_isIndex', './_isKey', './isLength', './isString'], function(castPath, isArguments, isArray, isIndex, isKey, isLength, isString) {
/**
* Checks if `path` exists on `object`.
@@ -10,7 +10,7 @@ define(['./_baseCastPath', './isArguments', './isArray', './_isIndex', './_isKey
* @returns {boolean} Returns `true` if `path` exists, else `false`.
*/
function hasPath(object, path, hasFunc) {
- path = isKey(path, object) ? [path] : baseCastPath(path);
+ path = isKey(path, object) ? [path] : castPath(path);
var result,
index = -1,
diff --git a/_reHasComplexSymbol.js b/_reHasComplexSymbol.js
new file mode 100644
index 000000000..887f25aa3
--- /dev/null
+++ b/_reHasComplexSymbol.js
@@ -0,0 +1,16 @@
+define([], function() {
+
+ /** Used to compose unicode character classes. */
+ var rsAstralRange = '\\ud800-\\udfff',
+ 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 + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
+
+ return reHasComplexSymbol;
+});
diff --git a/_stringSize.js b/_stringSize.js
index a5afdcbe6..f080172fe 100644
--- a/_stringSize.js
+++ b/_stringSize.js
@@ -1,4 +1,4 @@
-define([], function() {
+define(['./_reHasComplexSymbol'], function(reHasComplexSymbol) {
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
@@ -26,9 +26,6 @@ define([], function() {
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
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 + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
-
/**
* Gets the number of symbols in `string`.
*
diff --git a/_baseCastKey.js b/_toKey.js
similarity index 54%
rename from _baseCastKey.js
rename to _toKey.js
index 40b9f0626..965d6ef76 100644
--- a/_baseCastKey.js
+++ b/_toKey.js
@@ -1,15 +1,15 @@
define(['./isSymbol'], function(isSymbol) {
/**
- * Casts `value` to a string if it's not a string or symbol.
+ * Converts `value` to a string key if it's not a string or symbol.
*
* @private
* @param {*} value The value to inspect.
- * @returns {string|symbol} Returns the cast key.
+ * @returns {string|symbol} Returns the key.
*/
- function baseCastKey(key) {
+ function toKey(key) {
return (typeof key == 'string' || isSymbol(key)) ? key : (key + '');
}
- return baseCastKey;
+ return toKey;
});
diff --git a/at.js b/at.js
index 25d98085e..5acf98609 100644
--- a/at.js
+++ b/at.js
@@ -8,8 +8,7 @@ define(['./_baseAt', './_baseFlatten', './rest'], function(baseAt, baseFlatten,
* @since 1.0.0
* @category Object
* @param {Object} object The object to iterate over.
- * @param {...(string|string[])} [paths] The property paths of elements to pick,
- * specified individually or in arrays.
+ * @param {...(string|string[])} [paths] The property paths of elements to pick.
* @returns {Array} Returns the new array of picked elements.
* @example
*
diff --git a/bindAll.js b/bindAll.js
index 8688e1b5b..56b15c78a 100644
--- a/bindAll.js
+++ b/bindAll.js
@@ -11,8 +11,7 @@ define(['./_arrayEach', './_baseFlatten', './bind', './rest'], function(arrayEac
* @memberOf _
* @category Util
* @param {Object} object The object to bind and assign the bound methods to.
- * @param {...(string|string[])} methodNames The object method names to bind,
- * specified individually or in arrays.
+ * @param {...(string|string[])} methodNames The object method names to bind.
* @returns {Object} Returns `object`.
* @example
*
diff --git a/cond.js b/cond.js
index b849f8095..cc9652107 100644
--- a/cond.js
+++ b/cond.js
@@ -4,7 +4,7 @@ define(['./_apply', './_arrayMap', './_baseIteratee', './rest'], function(apply,
var FUNC_ERROR_TEXT = 'Expected a function';
/**
- * Creates a function that iterates over `pairs` invoking the corresponding
+ * Creates a function that iterates over `pairs` and invokes the corresponding
* function of the first predicate to return truthy. The predicate-function
* pairs are invoked with the `this` binding and arguments of the created
* function.
diff --git a/debounce.js b/debounce.js
index 3bafaeb82..4ffbae3ad 100644
--- a/debounce.js
+++ b/debounce.js
@@ -170,6 +170,9 @@ define(['./isObject', './now', './toNumber'], function(isObject, now, toNumber)
timerId = setTimeout(timerExpired, wait);
return invokeFunc(lastCallTime);
}
+ if (timerId === undefined) {
+ timerId = setTimeout(timerExpired, wait);
+ }
return result;
}
debounced.cancel = cancel;
diff --git a/forEach.js b/forEach.js
index e3b60b001..cdbd3dc12 100644
--- a/forEach.js
+++ b/forEach.js
@@ -1,7 +1,7 @@
define(['./_arrayEach', './_baseEach', './_baseIteratee', './isArray'], function(arrayEach, baseEach, baseIteratee, isArray) {
/**
- * Iterates over elements of `collection` invoking `iteratee` for each element.
+ * Iterates over elements of `collection` and invokes `iteratee` for each element.
* The iteratee is invoked with three arguments: (value, index|key, collection).
* Iteratee functions may exit iteration early by explicitly returning `false`.
*
diff --git a/forIn.js b/forIn.js
index d79fba995..8f380bafa 100644
--- a/forIn.js
+++ b/forIn.js
@@ -2,9 +2,9 @@ define(['./_baseFor', './_baseIteratee', './keysIn'], function(baseFor, baseIter
/**
* Iterates over own and inherited enumerable string keyed properties of an
- * object invoking `iteratee` for each property. The iteratee is invoked with
- * three arguments: (value, key, object). Iteratee functions may exit iteration
- * early by explicitly returning `false`.
+ * object and invokes `iteratee` for each property. The iteratee is invoked
+ * with three arguments: (value, key, object). Iteratee functions may exit
+ * iteration early by explicitly returning `false`.
*
* @static
* @memberOf _
diff --git a/forOwn.js b/forOwn.js
index 311188d8d..4090b2752 100644
--- a/forOwn.js
+++ b/forOwn.js
@@ -1,10 +1,10 @@
define(['./_baseForOwn', './_baseIteratee'], function(baseForOwn, baseIteratee) {
/**
- * Iterates over own enumerable string keyed properties of an object invoking
- * `iteratee` for each property. The iteratee is invoked with three arguments:
- * (value, key, object). Iteratee functions may exit iteration early by
- * explicitly returning `false`.
+ * Iterates over own enumerable string keyed properties of an object and
+ * invokes `iteratee` for each property. The iteratee is invoked with three
+ * arguments: (value, key, object). Iteratee functions may exit iteration
+ * early by explicitly returning `false`.
*
* @static
* @memberOf _
diff --git a/intersection.js b/intersection.js
index 1a7a89e75..63eefedd0 100644
--- a/intersection.js
+++ b/intersection.js
@@ -1,4 +1,4 @@
-define(['./_arrayMap', './_baseCastArrayLikeObject', './_baseIntersection', './rest'], function(arrayMap, baseCastArrayLikeObject, baseIntersection, rest) {
+define(['./_arrayMap', './_baseIntersection', './_castArrayLikeObject', './rest'], function(arrayMap, baseIntersection, castArrayLikeObject, rest) {
/**
* Creates an array of unique values that are included in all given arrays
@@ -18,7 +18,7 @@ define(['./_arrayMap', './_baseCastArrayLikeObject', './_baseIntersection', './r
* // => [2]
*/
var intersection = rest(function(arrays) {
- var mapped = arrayMap(arrays, baseCastArrayLikeObject);
+ var mapped = arrayMap(arrays, castArrayLikeObject);
return (mapped.length && mapped[0] === arrays[0])
? baseIntersection(mapped)
: [];
diff --git a/intersectionBy.js b/intersectionBy.js
index 6d5447b3e..cacbe9496 100644
--- a/intersectionBy.js
+++ b/intersectionBy.js
@@ -1,4 +1,4 @@
-define(['./_arrayMap', './_baseCastArrayLikeObject', './_baseIntersection', './_baseIteratee', './last', './rest'], function(arrayMap, baseCastArrayLikeObject, baseIntersection, baseIteratee, last, rest) {
+define(['./_arrayMap', './_baseIntersection', './_baseIteratee', './_castArrayLikeObject', './last', './rest'], function(arrayMap, baseIntersection, baseIteratee, castArrayLikeObject, last, rest) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -28,7 +28,7 @@ define(['./_arrayMap', './_baseCastArrayLikeObject', './_baseIntersection', './_
*/
var intersectionBy = rest(function(arrays) {
var iteratee = last(arrays),
- mapped = arrayMap(arrays, baseCastArrayLikeObject);
+ mapped = arrayMap(arrays, castArrayLikeObject);
if (iteratee === last(mapped)) {
iteratee = undefined;
diff --git a/intersectionWith.js b/intersectionWith.js
index faf2a3061..c04567e33 100644
--- a/intersectionWith.js
+++ b/intersectionWith.js
@@ -1,4 +1,4 @@
-define(['./_arrayMap', './_baseCastArrayLikeObject', './_baseIntersection', './last', './rest'], function(arrayMap, baseCastArrayLikeObject, baseIntersection, last, rest) {
+define(['./_arrayMap', './_baseIntersection', './_castArrayLikeObject', './last', './rest'], function(arrayMap, baseIntersection, castArrayLikeObject, last, rest) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -26,7 +26,7 @@ define(['./_arrayMap', './_baseCastArrayLikeObject', './_baseIntersection', './l
*/
var intersectionWith = rest(function(arrays) {
var comparator = last(arrays),
- mapped = arrayMap(arrays, baseCastArrayLikeObject);
+ mapped = arrayMap(arrays, castArrayLikeObject);
if (comparator === last(mapped)) {
comparator = undefined;
diff --git a/main.js b/main.js
index faae1d357..2ef4dd477 100644
--- a/main.js
+++ b/main.js
@@ -1,6 +1,6 @@
/**
* @license
- * lodash 4.9.0 (Custom Build)
+ * lodash 4.10.0 (Custom Build)
* Build: `lodash exports="amd" -d -o ./main.js`
* Copyright jQuery Foundation and other contributors
* Released under MIT license
@@ -13,7 +13,7 @@
var undefined;
/** Used as the semantic version number. */
- var VERSION = '4.9.0';
+ var VERSION = '4.10.0';
/** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200;
@@ -131,6 +131,9 @@
reTrimStart = /^\s+/,
reTrimEnd = /\s+$/;
+ /** Used to match non-compound words composed of alphanumeric characters. */
+ var reBasicWord = /[a-zA-Z0-9]+/g;
+
/** Used to match backslashes in property paths. */
var reEscapeChar = /\\(\\)?/g;
@@ -219,12 +222,6 @@
/** Used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
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 + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
-
- /** Used to match non-compound words composed of alphanumeric characters. */
- var reBasicWord = /[a-zA-Z0-9]+/g;
-
/** Used to match complex or compound words. */
var reComplexWord = RegExp([
rsUpper + '?' + rsLower + '+(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
@@ -235,6 +232,9 @@
rsEmoji
].join('|'), '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 + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
+
/** Used to detect strings that need a more robust regexp to match words. */
var reHasComplexWord = /[a-z][A-Z]|[A-Z]{2,}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
@@ -2357,50 +2357,6 @@
return result;
}
- /**
- * Casts `value` to an empty array if it's not an array like object.
- *
- * @private
- * @param {*} value The value to inspect.
- * @returns {Array|Object} Returns the cast array-like object.
- */
- function baseCastArrayLikeObject(value) {
- return isArrayLikeObject(value) ? value : [];
- }
-
- /**
- * Casts `value` to `identity` if it's not a function.
- *
- * @private
- * @param {*} value The value to inspect.
- * @returns {Function} Returns cast function.
- */
- function baseCastFunction(value) {
- return typeof value == 'function' ? value : identity;
- }
-
- /**
- * Casts `value` to a string if it's not a string or symbol.
- *
- * @private
- * @param {*} value The value to inspect.
- * @returns {string|symbol} Returns the cast key.
- */
- function baseCastKey(key) {
- return (typeof key == 'string' || isSymbol(key)) ? key : (key + '');
- }
-
- /**
- * Casts `value` to a path array if it's not one.
- *
- * @private
- * @param {*} value The value to inspect.
- * @returns {Array} Returns the cast property path array.
- */
- function baseCastPath(value) {
- return isArray(value) ? value : stringToPath(value);
- }
-
/**
* The base implementation of `_.clamp` which doesn't coerce arguments to numbers.
*
@@ -2731,7 +2687,7 @@
/**
* The base implementation of `baseForOwn` which iterates over `object`
- * properties returned by `keysFunc` invoking `iteratee` for each property.
+ * properties returned by `keysFunc` and invokes `iteratee` for each property.
* Iteratee functions may exit iteration early by explicitly returning `false`.
*
* @private
@@ -2802,7 +2758,7 @@
* @returns {*} Returns the resolved value.
*/
function baseGet(object, path) {
- path = isKey(path, object) ? [path] : baseCastPath(path);
+ path = isKey(path, object) ? [path] : castPath(path);
var index = 0,
length = path.length;
@@ -2964,7 +2920,7 @@
*/
function baseInvoke(object, path, args) {
if (!isKey(path, object)) {
- path = baseCastPath(path);
+ path = castPath(path);
object = parent(object, path);
path = last(path);
}
@@ -3486,7 +3442,7 @@
splice.call(array, index, 1);
}
else if (!isKey(index, array)) {
- var path = baseCastPath(index),
+ var path = castPath(index),
object = parent(array, path);
if (object != null) {
@@ -3576,7 +3532,7 @@
* @returns {Object} Returns `object`.
*/
function baseSet(object, path, value, customizer) {
- path = isKey(path, object) ? [path] : baseCastPath(path);
+ path = isKey(path, object) ? [path] : castPath(path);
var index = -1,
length = path.length,
@@ -3855,7 +3811,7 @@
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
*/
function baseUnset(object, path) {
- path = isKey(path, object) ? [path] : baseCastPath(path);
+ path = isKey(path, object) ? [path] : castPath(path);
object = parent(object, path);
var key = last(path);
return (object != null && has(object, key)) ? delete object[key] : true;
@@ -3965,6 +3921,54 @@
return result;
}
+ /**
+ * Casts `value` to an empty array if it's not an array like object.
+ *
+ * @private
+ * @param {*} value The value to inspect.
+ * @returns {Array|Object} Returns the cast array-like object.
+ */
+ function castArrayLikeObject(value) {
+ return isArrayLikeObject(value) ? value : [];
+ }
+
+ /**
+ * Casts `value` to `identity` if it's not a function.
+ *
+ * @private
+ * @param {*} value The value to inspect.
+ * @returns {Function} Returns cast function.
+ */
+ function castFunction(value) {
+ return typeof value == 'function' ? value : identity;
+ }
+
+ /**
+ * Casts `value` to a path array if it's not one.
+ *
+ * @private
+ * @param {*} value The value to inspect.
+ * @returns {Array} Returns the cast property path array.
+ */
+ function castPath(value) {
+ return isArray(value) ? value : stringToPath(value);
+ }
+
+ /**
+ * Casts `array` to a slice if it's needed.
+ *
+ * @private
+ * @param {Array} array The array to inspect.
+ * @param {number} start The start position.
+ * @param {number} [end=array.length] The end position.
+ * @returns {Array} Returns the cast slice.
+ */
+ function castSlice(array, start, end) {
+ var length = array.length;
+ end = end === undefined ? length : end;
+ return (!start && end >= length) ? array : baseSlice(array, start, end);
+ }
+
/**
* Creates a clone of `buffer`.
*
@@ -4358,8 +4362,13 @@
? stringToArray(string)
: undefined;
- var chr = strSymbols ? strSymbols[0] : string.charAt(0),
- trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1);
+ var chr = strSymbols
+ ? strSymbols[0]
+ : string.charAt(0);
+
+ var trailing = strSymbols
+ ? castSlice(strSymbols, 1).join('')
+ : string.slice(1);
return chr[methodName]() + trailing;
};
@@ -4638,7 +4647,7 @@
}
var result = baseRepeat(chars, nativeCeil(length / stringSize(chars)));
return reHasComplexSymbol.test(chars)
- ? stringToArray(result).slice(0, length).join('')
+ ? castSlice(stringToArray(result), 0, length).join('')
: result.slice(0, length);
}
@@ -5346,7 +5355,7 @@
* @returns {boolean} Returns `true` if `path` exists, else `false`.
*/
function hasPath(object, path, hasFunc) {
- path = isKey(path, object) ? [path] : baseCastPath(path);
+ path = isKey(path, object) ? [path] : castPath(path);
var result,
index = -1,
@@ -5784,6 +5793,17 @@
return result;
});
+ /**
+ * Converts `value` to a string key if it's not a string or symbol.
+ *
+ * @private
+ * @param {*} value The value to inspect.
+ * @returns {string|symbol} Returns the key.
+ */
+ function toKey(key) {
+ return (typeof key == 'string' || isSymbol(key)) ? key : (key + '');
+ }
+
/**
* Converts `func` to its source code.
*
@@ -6482,7 +6502,7 @@
* // => [2]
*/
var intersection = rest(function(arrays) {
- var mapped = arrayMap(arrays, baseCastArrayLikeObject);
+ var mapped = arrayMap(arrays, castArrayLikeObject);
return (mapped.length && mapped[0] === arrays[0])
? baseIntersection(mapped)
: [];
@@ -6513,7 +6533,7 @@
*/
var intersectionBy = rest(function(arrays) {
var iteratee = last(arrays),
- mapped = arrayMap(arrays, baseCastArrayLikeObject);
+ mapped = arrayMap(arrays, castArrayLikeObject);
if (iteratee === last(mapped)) {
iteratee = undefined;
@@ -6548,7 +6568,7 @@
*/
var intersectionWith = rest(function(arrays) {
var comparator = last(arrays),
- mapped = arrayMap(arrays, baseCastArrayLikeObject);
+ mapped = arrayMap(arrays, castArrayLikeObject);
if (comparator === last(mapped)) {
comparator = undefined;
@@ -6765,8 +6785,7 @@
* @since 3.0.0
* @category Array
* @param {Array} array The array to modify.
- * @param {...(number|number[])} [indexes] The indexes of elements to remove,
- * specified individually or in arrays.
+ * @param {...(number|number[])} [indexes] The indexes of elements to remove.
* @returns {Array} Returns the new array of removed elements.
* @example
*
@@ -7774,8 +7793,7 @@
* @memberOf _
* @since 1.0.0
* @category Seq
- * @param {...(string|string[])} [paths] The property paths of elements to pick,
- * specified individually or in arrays.
+ * @param {...(string|string[])} [paths] The property paths of elements to pick.
* @returns {Object} Returns the new `lodash` wrapper instance.
* @example
*
@@ -8292,7 +8310,7 @@
}
/**
- * Iterates over elements of `collection` invoking `iteratee` for each element.
+ * Iterates over elements of `collection` and invokes `iteratee` for each element.
* The iteratee is invoked with three arguments: (value, index|key, collection).
* Iteratee functions may exit iteration early by explicitly returning `false`.
*
@@ -8506,8 +8524,8 @@
* The guarded methods are:
* `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
* `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
- * `sampleSize`, `slice`, `some`, `sortBy`, `take`, `takeRight`, `template`,
- * `trim`, `trimEnd`, `trimStart`, and `words`
+ * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
+ * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
*
* @static
* @memberOf _
@@ -8917,8 +8935,7 @@
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
- * [iteratees=[_.identity]] The iteratees to sort by, specified individually
- * or in arrays.
+ * [iteratees=[_.identity]] The iteratees to sort by.
* @returns {Array} Returns the new sorted array.
* @example
*
@@ -8948,7 +8965,7 @@
if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
iteratees = [];
} else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
- iteratees.length = 1;
+ iteratees = [iteratees[0]];
}
return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
});
@@ -9420,6 +9437,9 @@
timerId = setTimeout(timerExpired, wait);
return invokeFunc(lastCallTime);
}
+ if (timerId === undefined) {
+ timerId = setTimeout(timerExpired, wait);
+ }
return result;
}
debounced.cancel = cancel;
@@ -9621,8 +9641,8 @@
* @memberOf _
* @category Function
* @param {Function} func The function to wrap.
- * @param {...(Function|Function[])} [transforms] The functions to transform.
- * arguments, specified individually or in arrays.
+ * @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
+ * [transforms[_.identity]] The functions to transform.
* @returns {Function} Returns the new function.
* @example
*
@@ -9744,8 +9764,7 @@
* @since 3.0.0
* @category Function
* @param {Function} func The function to rearrange arguments for.
- * @param {...(number|number[])} indexes The arranged argument indexes,
- * specified individually or in arrays.
+ * @param {...(number|number[])} indexes The arranged argument indexes.
* @returns {Function} Returns the new function.
* @example
*
@@ -9855,7 +9874,7 @@
start = start === undefined ? 0 : nativeMax(toInteger(start), 0);
return rest(function(args) {
var array = args[start],
- otherArgs = args.slice(0, start);
+ otherArgs = castSlice(args, 0, start);
if (array) {
arrayPush(otherArgs, array);
@@ -11503,8 +11522,8 @@
}
/**
- * Converts `value` to a string if it's not one. An empty string is returned
- * for `null` and `undefined` values. The sign of `-0` is preserved.
+ * Converts `value` to a string. An empty string is returned for `null`
+ * and `undefined` values. The sign of `-0` is preserved.
*
* @static
* @memberOf _
@@ -11694,8 +11713,7 @@
* @since 1.0.0
* @category Object
* @param {Object} object The object to iterate over.
- * @param {...(string|string[])} [paths] The property paths of elements to pick,
- * specified individually or in arrays.
+ * @param {...(string|string[])} [paths] The property paths of elements to pick.
* @returns {Array} Returns the new array of picked elements.
* @example
*
@@ -11881,9 +11899,9 @@
/**
* Iterates over own and inherited enumerable string keyed properties of an
- * object invoking `iteratee` for each property. The iteratee is invoked with
- * three arguments: (value, key, object). Iteratee functions may exit iteration
- * early by explicitly returning `false`.
+ * object and invokes `iteratee` for each property. The iteratee is invoked
+ * with three arguments: (value, key, object). Iteratee functions may exit
+ * iteration early by explicitly returning `false`.
*
* @static
* @memberOf _
@@ -11944,10 +11962,10 @@
}
/**
- * Iterates over own enumerable string keyed properties of an object invoking
- * `iteratee` for each property. The iteratee is invoked with three arguments:
- * (value, key, object). Iteratee functions may exit iteration early by
- * explicitly returning `false`.
+ * Iterates over own enumerable string keyed properties of an object and
+ * invokes `iteratee` for each property. The iteratee is invoked with three
+ * arguments: (value, key, object). Iteratee functions may exit iteration
+ * early by explicitly returning `false`.
*
* @static
* @memberOf _
@@ -12470,8 +12488,7 @@
* @memberOf _
* @category Object
* @param {Object} object The source object.
- * @param {...(string|string[])} [props] The property identifiers to omit,
- * specified individually or in arrays.
+ * @param {...(string|string[])} [props] The property identifiers to omit.
* @returns {Object} Returns the new object.
* @example
*
@@ -12484,7 +12501,7 @@
if (object == null) {
return {};
}
- props = arrayMap(baseFlatten(props, 1), baseCastKey);
+ props = arrayMap(baseFlatten(props, 1), toKey);
return basePick(object, baseDifference(getAllKeysIn(object), props));
});
@@ -12524,8 +12541,7 @@
* @memberOf _
* @category Object
* @param {Object} object The source object.
- * @param {...(string|string[])} [props] The property identifiers to pick,
- * specified individually or in arrays.
+ * @param {...(string|string[])} [props] The property identifiers to pick.
* @returns {Object} Returns the new object.
* @example
*
@@ -12591,7 +12607,7 @@
* // => 'default'
*/
function result(object, path, defaultValue) {
- path = isKey(path, object) ? [path] : baseCastPath(path);
+ path = isKey(path, object) ? [path] : castPath(path);
var index = -1,
length = path.length;
@@ -12837,7 +12853,7 @@
* // => 0
*/
function update(object, path, updater) {
- return object == null ? object : baseUpdate(object, path, baseCastFunction(updater));
+ return object == null ? object : baseUpdate(object, path, castFunction(updater));
}
/**
@@ -12866,7 +12882,7 @@
*/
function updateWith(object, path, updater, customizer) {
customizer = typeof customizer == 'function' ? customizer : undefined;
- return object == null ? object : baseUpdate(object, path, baseCastFunction(updater), customizer);
+ return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
}
/**
@@ -13561,6 +13577,13 @@
* // => ['a', 'b']
*/
function split(string, separator, limit) {
+ if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
+ separator = limit = undefined;
+ }
+ limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
+ if (!limit) {
+ return [];
+ }
string = toString(string);
if (string && (
typeof separator == 'string' ||
@@ -13568,8 +13591,7 @@
)) {
separator += '';
if (separator == '' && reHasComplexSymbol.test(string)) {
- var strSymbols = stringToArray(string);
- return limit === undefined ? strSymbols : strSymbols.slice(0, limit < 0 ? 0 : limit);
+ return castSlice(stringToArray(string), 0, limit);
}
}
return string.split(separator, limit);
@@ -13920,16 +13942,15 @@
if (guard || chars === undefined) {
return string.replace(reTrim, '');
}
- chars = (chars + '');
- if (!chars) {
+ if (!(chars += '')) {
return string;
}
var strSymbols = stringToArray(string),
- chrSymbols = stringToArray(chars);
+ chrSymbols = stringToArray(chars),
+ start = charsStartIndex(strSymbols, chrSymbols),
+ end = charsEndIndex(strSymbols, chrSymbols) + 1;
- return strSymbols
- .slice(charsStartIndex(strSymbols, chrSymbols), charsEndIndex(strSymbols, chrSymbols) + 1)
- .join('');
+ return castSlice(strSymbols, start, end).join('');
}
/**
@@ -13959,14 +13980,13 @@
if (guard || chars === undefined) {
return string.replace(reTrimEnd, '');
}
- chars = (chars + '');
- if (!chars) {
+ if (!(chars += '')) {
return string;
}
- var strSymbols = stringToArray(string);
- return strSymbols
- .slice(0, charsEndIndex(strSymbols, stringToArray(chars)) + 1)
- .join('');
+ var strSymbols = stringToArray(string),
+ end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
+
+ return castSlice(strSymbols, 0, end).join('');
}
/**
@@ -13996,14 +14016,13 @@
if (guard || chars === undefined) {
return string.replace(reTrimStart, '');
}
- chars = (chars + '');
- if (!chars) {
+ if (!(chars += '')) {
return string;
}
- var strSymbols = stringToArray(string);
- return strSymbols
- .slice(charsStartIndex(strSymbols, stringToArray(chars)))
- .join('');
+ var strSymbols = stringToArray(string),
+ start = charsStartIndex(strSymbols, stringToArray(chars));
+
+ return castSlice(strSymbols, start).join('');
}
/**
@@ -14067,7 +14086,7 @@
return omission;
}
var result = strSymbols
- ? strSymbols.slice(0, end).join('')
+ ? castSlice(strSymbols, 0, end).join('')
: string.slice(0, end);
if (separator === undefined) {
@@ -14240,8 +14259,7 @@
* @memberOf _
* @category Util
* @param {Object} object The object to bind and assign the bound methods to.
- * @param {...(string|string[])} methodNames The object method names to bind,
- * specified individually or in arrays.
+ * @param {...(string|string[])} methodNames The object method names to bind.
* @returns {Object} Returns `object`.
* @example
*
@@ -14264,7 +14282,7 @@
});
/**
- * Creates a function that iterates over `pairs` invoking the corresponding
+ * Creates a function that iterates over `pairs` and invokes the corresponding
* function of the first predicate to return truthy. The predicate-function
* pairs are invoked with the `this` binding and arguments of the created
* function.
@@ -14730,7 +14748,8 @@
* @memberOf _
* @since 4.0.0
* @category Util
- * @param {...(Function|Function[])} iteratees The iteratees to invoke.
+ * @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
+ * [iteratees=[_.identity]] The iteratees to invoke.
* @returns {Function} Returns the new function.
* @example
*
@@ -14749,7 +14768,8 @@
* @memberOf _
* @since 4.0.0
* @category Util
- * @param {...(Function|Function[])} predicates The predicates to check.
+ * @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
+ * [predicates=[_.identity]] The predicates to check.
* @returns {Function} Returns the new function.
* @example
*
@@ -14774,7 +14794,8 @@
* @memberOf _
* @since 4.0.0
* @category Util
- * @param {...(Function|Function[])} predicates The predicates to check.
+ * @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
+ * [predicates=[_.identity]] The predicates to check.
* @returns {Function} Returns the new function.
* @example
*
@@ -14988,7 +15009,7 @@
*/
function toPath(value) {
if (isArray(value)) {
- return arrayMap(value, baseCastKey);
+ return arrayMap(value, toKey);
}
return isSymbol(value) ? [value] : copyArray(stringToPath(value));
}
diff --git a/map.js b/map.js
index eceb4e6c5..32780cc15 100644
--- a/map.js
+++ b/map.js
@@ -11,8 +11,8 @@ define(['./_arrayMap', './_baseIteratee', './_baseMap', './isArray'], function(a
* The guarded methods are:
* `ary`, `chunk`, `curry`, `curryRight`, `drop`, `dropRight`, `every`,
* `fill`, `invert`, `parseInt`, `random`, `range`, `rangeRight`, `repeat`,
- * `sampleSize`, `slice`, `some`, `sortBy`, `take`, `takeRight`, `template`,
- * `trim`, `trimEnd`, `trimStart`, and `words`
+ * `sampleSize`, `slice`, `some`, `sortBy`, `split`, `take`, `takeRight`,
+ * `template`, `trim`, `trimEnd`, `trimStart`, and `words`
*
* @static
* @memberOf _
diff --git a/omit.js b/omit.js
index be537017f..304dc822d 100644
--- a/omit.js
+++ b/omit.js
@@ -1,4 +1,4 @@
-define(['./_arrayMap', './_baseCastKey', './_baseDifference', './_baseFlatten', './_basePick', './_getAllKeysIn', './rest'], function(arrayMap, baseCastKey, baseDifference, baseFlatten, basePick, getAllKeysIn, rest) {
+define(['./_arrayMap', './_baseDifference', './_baseFlatten', './_basePick', './_getAllKeysIn', './rest', './_toKey'], function(arrayMap, baseDifference, baseFlatten, basePick, getAllKeysIn, rest, toKey) {
/**
* The opposite of `_.pick`; this method creates an object composed of the
@@ -10,8 +10,7 @@ define(['./_arrayMap', './_baseCastKey', './_baseDifference', './_baseFlatten',
* @memberOf _
* @category Object
* @param {Object} object The source object.
- * @param {...(string|string[])} [props] The property identifiers to omit,
- * specified individually or in arrays.
+ * @param {...(string|string[])} [props] The property identifiers to omit.
* @returns {Object} Returns the new object.
* @example
*
@@ -24,7 +23,7 @@ define(['./_arrayMap', './_baseCastKey', './_baseDifference', './_baseFlatten',
if (object == null) {
return {};
}
- props = arrayMap(baseFlatten(props, 1), baseCastKey);
+ props = arrayMap(baseFlatten(props, 1), toKey);
return basePick(object, baseDifference(getAllKeysIn(object), props));
});
diff --git a/over.js b/over.js
index 597da9bb0..68f36a2b4 100644
--- a/over.js
+++ b/over.js
@@ -8,7 +8,8 @@ define(['./_arrayMap', './_createOver'], function(arrayMap, createOver) {
* @memberOf _
* @since 4.0.0
* @category Util
- * @param {...(Function|Function[])} iteratees The iteratees to invoke.
+ * @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
+ * [iteratees=[_.identity]] The iteratees to invoke.
* @returns {Function} Returns the new function.
* @example
*
diff --git a/overArgs.js b/overArgs.js
index 14f6e7d77..ed51db195 100644
--- a/overArgs.js
+++ b/overArgs.js
@@ -12,8 +12,8 @@ define(['./_apply', './_arrayMap', './_baseFlatten', './_baseIteratee', './_isFl
* @memberOf _
* @category Function
* @param {Function} func The function to wrap.
- * @param {...(Function|Function[])} [transforms] The functions to transform.
- * arguments, specified individually or in arrays.
+ * @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
+ * [transforms[_.identity]] The functions to transform.
* @returns {Function} Returns the new function.
* @example
*
diff --git a/overEvery.js b/overEvery.js
index 4f7990887..76fca2cf3 100644
--- a/overEvery.js
+++ b/overEvery.js
@@ -8,7 +8,8 @@ define(['./_arrayEvery', './_createOver'], function(arrayEvery, createOver) {
* @memberOf _
* @since 4.0.0
* @category Util
- * @param {...(Function|Function[])} predicates The predicates to check.
+ * @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
+ * [predicates=[_.identity]] The predicates to check.
* @returns {Function} Returns the new function.
* @example
*
diff --git a/overSome.js b/overSome.js
index 0609e9e44..17106a753 100644
--- a/overSome.js
+++ b/overSome.js
@@ -8,7 +8,8 @@ define(['./_arraySome', './_createOver'], function(arraySome, createOver) {
* @memberOf _
* @since 4.0.0
* @category Util
- * @param {...(Function|Function[])} predicates The predicates to check.
+ * @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
+ * [predicates=[_.identity]] The predicates to check.
* @returns {Function} Returns the new function.
* @example
*
diff --git a/package.json b/package.json
index 6d2c90ccd..5c08c381c 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "lodash-amd",
- "version": "4.9.0",
+ "version": "4.10.0",
"description": "Lodash exported as AMD modules.",
"homepage": "https://lodash.com/custom-builds",
"license": "MIT",
diff --git a/pick.js b/pick.js
index 52d6ffc8d..14c45b3d1 100644
--- a/pick.js
+++ b/pick.js
@@ -8,8 +8,7 @@ define(['./_baseFlatten', './_basePick', './rest'], function(baseFlatten, basePi
* @memberOf _
* @category Object
* @param {Object} object The source object.
- * @param {...(string|string[])} [props] The property identifiers to pick,
- * specified individually or in arrays.
+ * @param {...(string|string[])} [props] The property identifiers to pick.
* @returns {Object} Returns the new object.
* @example
*
diff --git a/pullAt.js b/pullAt.js
index 77518365e..763370356 100644
--- a/pullAt.js
+++ b/pullAt.js
@@ -11,8 +11,7 @@ define(['./_arrayMap', './_baseAt', './_baseFlatten', './_basePullAt', './_compa
* @since 3.0.0
* @category Array
* @param {Array} array The array to modify.
- * @param {...(number|number[])} [indexes] The indexes of elements to remove,
- * specified individually or in arrays.
+ * @param {...(number|number[])} [indexes] The indexes of elements to remove.
* @returns {Array} Returns the new array of removed elements.
* @example
*
diff --git a/rearg.js b/rearg.js
index 0d2ce4c88..85ff0b192 100644
--- a/rearg.js
+++ b/rearg.js
@@ -17,8 +17,7 @@ define(['./_baseFlatten', './_createWrapper', './rest'], function(baseFlatten, c
* @since 3.0.0
* @category Function
* @param {Function} func The function to rearrange arguments for.
- * @param {...(number|number[])} indexes The arranged argument indexes,
- * specified individually or in arrays.
+ * @param {...(number|number[])} indexes The arranged argument indexes.
* @returns {Function} Returns the new function.
* @example
*
diff --git a/result.js b/result.js
index be5a4f285..7e5fee6ac 100644
--- a/result.js
+++ b/result.js
@@ -1,4 +1,4 @@
-define(['./_baseCastPath', './isFunction', './_isKey'], function(baseCastPath, isFunction, isKey) {
+define(['./_castPath', './isFunction', './_isKey'], function(castPath, isFunction, isKey) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -33,7 +33,7 @@ define(['./_baseCastPath', './isFunction', './_isKey'], function(baseCastPath, i
* // => 'default'
*/
function result(object, path, defaultValue) {
- path = isKey(path, object) ? [path] : baseCastPath(path);
+ path = isKey(path, object) ? [path] : castPath(path);
var index = -1,
length = path.length;
diff --git a/sortBy.js b/sortBy.js
index d5a24223b..35382a22e 100644
--- a/sortBy.js
+++ b/sortBy.js
@@ -12,8 +12,7 @@ define(['./_baseFlatten', './_baseOrderBy', './_isIterateeCall', './rest'], func
* @category Collection
* @param {Array|Object} collection The collection to iterate over.
* @param {...(Array|Array[]|Function|Function[]|Object|Object[]|string|string[])}
- * [iteratees=[_.identity]] The iteratees to sort by, specified individually
- * or in arrays.
+ * [iteratees=[_.identity]] The iteratees to sort by.
* @returns {Array} Returns the new sorted array.
* @example
*
@@ -43,7 +42,7 @@ define(['./_baseFlatten', './_baseOrderBy', './_isIterateeCall', './rest'], func
if (length > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
iteratees = [];
} else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
- iteratees.length = 1;
+ iteratees = [iteratees[0]];
}
return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
});
diff --git a/split.js b/split.js
index 59cd3f172..f43e65151 100644
--- a/split.js
+++ b/split.js
@@ -1,19 +1,10 @@
-define(['./isRegExp', './_stringToArray', './toString'], function(isRegExp, stringToArray, toString) {
+define(['./_castSlice', './_isIterateeCall', './isRegExp', './_reHasComplexSymbol', './_stringToArray', './toString'], function(castSlice, isIterateeCall, isRegExp, reHasComplexSymbol, stringToArray, toString) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
- /** Used to compose unicode character classes. */
- var rsAstralRange = '\\ud800-\\udfff',
- 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 + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
+ /** Used as references for the maximum length and index of an array. */
+ var MAX_ARRAY_LENGTH = 4294967295;
/**
* Splits `string` by `separator`.
@@ -35,6 +26,13 @@ define(['./isRegExp', './_stringToArray', './toString'], function(isRegExp, stri
* // => ['a', 'b']
*/
function split(string, separator, limit) {
+ if (limit && typeof limit != 'number' && isIterateeCall(string, separator, limit)) {
+ separator = limit = undefined;
+ }
+ limit = limit === undefined ? MAX_ARRAY_LENGTH : limit >>> 0;
+ if (!limit) {
+ return [];
+ }
string = toString(string);
if (string && (
typeof separator == 'string' ||
@@ -42,8 +40,7 @@ define(['./isRegExp', './_stringToArray', './toString'], function(isRegExp, stri
)) {
separator += '';
if (separator == '' && reHasComplexSymbol.test(string)) {
- var strSymbols = stringToArray(string);
- return limit === undefined ? strSymbols : strSymbols.slice(0, limit < 0 ? 0 : limit);
+ return castSlice(stringToArray(string), 0, limit);
}
}
return string.split(separator, limit);
diff --git a/spread.js b/spread.js
index 8f4727644..c98c9a7b5 100644
--- a/spread.js
+++ b/spread.js
@@ -1,4 +1,4 @@
-define(['./_apply', './_arrayPush', './rest', './toInteger'], function(apply, arrayPush, rest, toInteger) {
+define(['./_apply', './_arrayPush', './_castSlice', './rest', './toInteger'], function(apply, arrayPush, castSlice, rest, toInteger) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -50,7 +50,7 @@ define(['./_apply', './_arrayPush', './rest', './toInteger'], function(apply, ar
start = start === undefined ? 0 : nativeMax(toInteger(start), 0);
return rest(function(args) {
var array = args[start],
- otherArgs = args.slice(0, start);
+ otherArgs = castSlice(args, 0, start);
if (array) {
arrayPush(otherArgs, array);
diff --git a/toPath.js b/toPath.js
index 8551dee88..0129319b8 100644
--- a/toPath.js
+++ b/toPath.js
@@ -1,4 +1,4 @@
-define(['./_arrayMap', './_baseCastKey', './_copyArray', './isArray', './isSymbol', './_stringToPath'], function(arrayMap, baseCastKey, copyArray, isArray, isSymbol, stringToPath) {
+define(['./_arrayMap', './_copyArray', './isArray', './isSymbol', './_stringToPath', './_toKey'], function(arrayMap, copyArray, isArray, isSymbol, stringToPath, toKey) {
/**
* Converts `value` to a property path array.
@@ -28,7 +28,7 @@ define(['./_arrayMap', './_baseCastKey', './_copyArray', './isArray', './isSymbo
*/
function toPath(value) {
if (isArray(value)) {
- return arrayMap(value, baseCastKey);
+ return arrayMap(value, toKey);
}
return isSymbol(value) ? [value] : copyArray(stringToPath(value));
}
diff --git a/toString.js b/toString.js
index 686bed692..56947e097 100644
--- a/toString.js
+++ b/toString.js
@@ -11,8 +11,8 @@ define(['./_Symbol', './isSymbol'], function(Symbol, isSymbol) {
symbolToString = symbolProto ? symbolProto.toString : undefined;
/**
- * Converts `value` to a string if it's not one. An empty string is returned
- * for `null` and `undefined` values. The sign of `-0` is preserved.
+ * Converts `value` to a string. An empty string is returned for `null`
+ * and `undefined` values. The sign of `-0` is preserved.
*
* @static
* @memberOf _
diff --git a/trim.js b/trim.js
index c6a61bd59..94116569d 100644
--- a/trim.js
+++ b/trim.js
@@ -1,4 +1,4 @@
-define(['./_charsEndIndex', './_charsStartIndex', './_stringToArray', './toString'], function(charsEndIndex, charsStartIndex, stringToArray, toString) {
+define(['./_castSlice', './_charsEndIndex', './_charsStartIndex', './_stringToArray', './toString'], function(castSlice, charsEndIndex, charsStartIndex, stringToArray, toString) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -36,16 +36,15 @@ define(['./_charsEndIndex', './_charsStartIndex', './_stringToArray', './toStrin
if (guard || chars === undefined) {
return string.replace(reTrim, '');
}
- chars = (chars + '');
- if (!chars) {
+ if (!(chars += '')) {
return string;
}
var strSymbols = stringToArray(string),
- chrSymbols = stringToArray(chars);
+ chrSymbols = stringToArray(chars),
+ start = charsStartIndex(strSymbols, chrSymbols),
+ end = charsEndIndex(strSymbols, chrSymbols) + 1;
- return strSymbols
- .slice(charsStartIndex(strSymbols, chrSymbols), charsEndIndex(strSymbols, chrSymbols) + 1)
- .join('');
+ return castSlice(strSymbols, start, end).join('');
}
return trim;
diff --git a/trimEnd.js b/trimEnd.js
index f6d3ab96e..6221b2fdd 100644
--- a/trimEnd.js
+++ b/trimEnd.js
@@ -1,4 +1,4 @@
-define(['./_charsEndIndex', './_stringToArray', './toString'], function(charsEndIndex, stringToArray, toString) {
+define(['./_castSlice', './_charsEndIndex', './_stringToArray', './toString'], function(castSlice, charsEndIndex, stringToArray, toString) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -33,14 +33,13 @@ define(['./_charsEndIndex', './_stringToArray', './toString'], function(charsEnd
if (guard || chars === undefined) {
return string.replace(reTrimEnd, '');
}
- chars = (chars + '');
- if (!chars) {
+ if (!(chars += '')) {
return string;
}
- var strSymbols = stringToArray(string);
- return strSymbols
- .slice(0, charsEndIndex(strSymbols, stringToArray(chars)) + 1)
- .join('');
+ var strSymbols = stringToArray(string),
+ end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
+
+ return castSlice(strSymbols, 0, end).join('');
}
return trimEnd;
diff --git a/trimStart.js b/trimStart.js
index 4ef48c8ec..e86aeeefe 100644
--- a/trimStart.js
+++ b/trimStart.js
@@ -1,4 +1,4 @@
-define(['./_charsStartIndex', './_stringToArray', './toString'], function(charsStartIndex, stringToArray, toString) {
+define(['./_castSlice', './_charsStartIndex', './_stringToArray', './toString'], function(castSlice, charsStartIndex, stringToArray, toString) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -33,14 +33,13 @@ define(['./_charsStartIndex', './_stringToArray', './toString'], function(charsS
if (guard || chars === undefined) {
return string.replace(reTrimStart, '');
}
- chars = (chars + '');
- if (!chars) {
+ if (!(chars += '')) {
return string;
}
- var strSymbols = stringToArray(string);
- return strSymbols
- .slice(charsStartIndex(strSymbols, stringToArray(chars)))
- .join('');
+ var strSymbols = stringToArray(string),
+ start = charsStartIndex(strSymbols, stringToArray(chars));
+
+ return castSlice(strSymbols, start).join('');
}
return trimStart;
diff --git a/truncate.js b/truncate.js
index af32287cd..f4047ec9d 100644
--- a/truncate.js
+++ b/truncate.js
@@ -1,4 +1,4 @@
-define(['./isObject', './isRegExp', './_stringSize', './_stringToArray', './toInteger', './toString'], function(isObject, isRegExp, stringSize, stringToArray, toInteger, toString) {
+define(['./_castSlice', './isObject', './isRegExp', './_reHasComplexSymbol', './_stringSize', './_stringToArray', './toInteger', './toString'], function(castSlice, isObject, isRegExp, reHasComplexSymbol, stringSize, stringToArray, toInteger, toString) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -10,18 +10,6 @@ define(['./isObject', './isRegExp', './_stringSize', './_stringToArray', './toIn
/** Used to match `RegExp` flags from their coerced string values. */
var reFlags = /\w*$/;
- /** Used to compose unicode character classes. */
- var rsAstralRange = '\\ud800-\\udfff',
- 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 + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
-
/**
* Truncates `string` if it's longer than the given maximum string length.
* The last characters of the truncated string are replaced with the omission
@@ -83,7 +71,7 @@ define(['./isObject', './isRegExp', './_stringSize', './_stringToArray', './toIn
return omission;
}
var result = strSymbols
- ? strSymbols.slice(0, end).join('')
+ ? castSlice(strSymbols, 0, end).join('')
: string.slice(0, end);
if (separator === undefined) {
diff --git a/update.js b/update.js
index 33022aa23..826434750 100644
--- a/update.js
+++ b/update.js
@@ -1,4 +1,4 @@
-define(['./_baseCastFunction', './_baseUpdate'], function(baseCastFunction, baseUpdate) {
+define(['./_baseUpdate', './_castFunction'], function(baseUpdate, castFunction) {
/**
* This method is like `_.set` except that accepts `updater` to produce the
@@ -28,7 +28,7 @@ define(['./_baseCastFunction', './_baseUpdate'], function(baseCastFunction, base
* // => 0
*/
function update(object, path, updater) {
- return object == null ? object : baseUpdate(object, path, baseCastFunction(updater));
+ return object == null ? object : baseUpdate(object, path, castFunction(updater));
}
return update;
diff --git a/updateWith.js b/updateWith.js
index 5523c9dc9..abc58f518 100644
--- a/updateWith.js
+++ b/updateWith.js
@@ -1,4 +1,4 @@
-define(['./_baseCastFunction', './_baseUpdate'], function(baseCastFunction, baseUpdate) {
+define(['./_baseUpdate', './_castFunction'], function(baseUpdate, castFunction) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -29,7 +29,7 @@ define(['./_baseCastFunction', './_baseUpdate'], function(baseCastFunction, base
*/
function updateWith(object, path, updater, customizer) {
customizer = typeof customizer == 'function' ? customizer : undefined;
- return object == null ? object : baseUpdate(object, path, baseCastFunction(updater), customizer);
+ return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
}
return updateWith;
diff --git a/words.js b/words.js
index 17879af24..cfb1cecac 100644
--- a/words.js
+++ b/words.js
@@ -3,6 +3,9 @@ define(['./toString'], function(toString) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
+ /** Used to match non-compound words composed of alphanumeric characters. */
+ var reBasicWord = /[a-zA-Z0-9]+/g;
+
/** Used to compose unicode character classes. */
var rsAstralRange = '\\ud800-\\udfff',
rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23',
@@ -41,9 +44,6 @@ define(['./toString'], function(toString) {
rsSeq = rsOptVar + reOptMod + rsOptJoin,
rsEmoji = '(?:' + [rsDingbat, rsRegional, rsSurrPair].join('|') + ')' + rsSeq;
- /** Used to match non-compound words composed of alphanumeric characters. */
- var reBasicWord = /[a-zA-Z0-9]+/g;
-
/** Used to match complex or compound words. */
var reComplexWord = RegExp([
rsUpper + '?' + rsLower + '+(?=' + [rsBreak, rsUpper, '$'].join('|') + ')',
diff --git a/wrapperAt.js b/wrapperAt.js
index 067b8f5ec..30e868e25 100644
--- a/wrapperAt.js
+++ b/wrapperAt.js
@@ -10,8 +10,7 @@ define(['./_LazyWrapper', './_LodashWrapper', './_baseAt', './_baseFlatten', './
* @memberOf _
* @since 1.0.0
* @category Seq
- * @param {...(string|string[])} [paths] The property paths of elements to pick,
- * specified individually or in arrays.
+ * @param {...(string|string[])} [paths] The property paths of elements to pick.
* @returns {Object} Returns the new `lodash` wrapper instance.
* @example
*