diff --git a/README.md b/README.md
index 585d27957..ecc32d62a 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# lodash-amd v4.3.0
+# lodash-amd v4.4.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.3.0-amd) for more details.
+See the [package source](https://github.com/lodash/lodash/tree/4.4.0-amd) for more details.
diff --git a/_Hash.js b/_Hash.js
index 630664137..b773cb614 100644
--- a/_Hash.js
+++ b/_Hash.js
@@ -7,6 +7,7 @@ define(['./_nativeCreate'], function(nativeCreate) {
* Creates an hash object.
*
* @private
+ * @constructor
* @returns {Object} Returns the new hash object.
*/
function Hash() {}
diff --git a/_LazyWrapper.js b/_LazyWrapper.js
index f2cd96e33..66062b0bf 100644
--- a/_LazyWrapper.js
+++ b/_LazyWrapper.js
@@ -7,6 +7,7 @@ define(['./_baseCreate', './_baseLodash'], function(baseCreate, baseLodash) {
* Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
*
* @private
+ * @constructor
* @param {*} value The value to wrap.
*/
function LazyWrapper(value) {
diff --git a/_MapCache.js b/_MapCache.js
index 4cbbec6ad..67e19b70c 100644
--- a/_MapCache.js
+++ b/_MapCache.js
@@ -4,6 +4,7 @@ define(['./_mapClear', './_mapDelete', './_mapGet', './_mapHas', './_mapSet'], f
* Creates a map cache object to store key-value pairs.
*
* @private
+ * @constructor
* @param {Array} [values] The values to cache.
*/
function MapCache(values) {
diff --git a/_SetCache.js b/_SetCache.js
index d76d6a24c..e25032495 100644
--- a/_SetCache.js
+++ b/_SetCache.js
@@ -5,6 +5,7 @@ define(['./_MapCache', './_cachePush'], function(MapCache, cachePush) {
* Creates a set cache object to store unique values.
*
* @private
+ * @constructor
* @param {Array} [values] The values to cache.
*/
function SetCache(values) {
diff --git a/_Stack.js b/_Stack.js
index ab8601af2..bd3cbc17e 100644
--- a/_Stack.js
+++ b/_Stack.js
@@ -4,6 +4,7 @@ define(['./_stackClear', './_stackDelete', './_stackGet', './_stackHas', './_sta
* Creates a stack cache object to store key-value pairs.
*
* @private
+ * @constructor
* @param {Array} [values] The values to cache.
*/
function Stack(values) {
diff --git a/_toArrayLikeObject.js b/_baseCastArrayLikeObject.js
similarity index 51%
rename from _toArrayLikeObject.js
rename to _baseCastArrayLikeObject.js
index 97449156f..1014ace5b 100644
--- a/_toArrayLikeObject.js
+++ b/_baseCastArrayLikeObject.js
@@ -1,15 +1,15 @@
define(['./isArrayLikeObject'], function(isArrayLikeObject) {
/**
- * Converts `value` to an array-like object if it's not one.
+ * Casts `value` to an empty array if it's not an array like object.
*
* @private
- * @param {*} value The value to process.
+ * @param {*} value The value to inspect.
* @returns {Array} Returns the array-like object.
*/
- function toArrayLikeObject(value) {
+ function baseCastArrayLikeObject(value) {
return isArrayLikeObject(value) ? value : [];
}
- return toArrayLikeObject;
+ return baseCastArrayLikeObject;
});
diff --git a/_baseCastFunction.js b/_baseCastFunction.js
new file mode 100644
index 000000000..842a7b8da
--- /dev/null
+++ b/_baseCastFunction.js
@@ -0,0 +1,15 @@
+define(['./identity'], function(identity) {
+
+ /**
+ * Casts `value` to `identity` if it's not a function.
+ *
+ * @private
+ * @param {*} value The value to inspect.
+ * @returns {Array} Returns the array-like object.
+ */
+ function baseCastFunction(value) {
+ return typeof value == 'function' ? value : identity;
+ }
+
+ return baseCastFunction;
+});
diff --git a/_baseCastPath.js b/_baseCastPath.js
new file mode 100644
index 000000000..b15bf14e8
--- /dev/null
+++ b/_baseCastPath.js
@@ -0,0 +1,15 @@
+define(['./isArray', './_stringToPath'], function(isArray, stringToPath) {
+
+ /**
+ * 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);
+ }
+
+ return baseCastPath;
+});
diff --git a/_baseCreate.js b/_baseCreate.js
index 91e355e53..64687dd98 100644
--- a/_baseCreate.js
+++ b/_baseCreate.js
@@ -1,7 +1,7 @@
define(['./isObject'], function(isObject) {
- /** Used as a safe reference for `undefined` in pre-ES5 environments. */
- var undefined;
+ /** Built-in value references. */
+ var objectCreate = Object.create;
/**
* The base implementation of `_.create` without support for assigning
@@ -11,17 +11,9 @@ define(['./isObject'], function(isObject) {
* @param {Object} prototype The object to inherit from.
* @returns {Object} Returns the new object.
*/
- var baseCreate = (function() {
- function object() {}
- return function(prototype) {
- if (isObject(prototype)) {
- object.prototype = prototype;
- var result = new object;
- object.prototype = undefined;
- }
- return result || {};
- };
- }());
+ function baseCreate(proto) {
+ return isObject(proto) ? objectCreate(proto) : {};
+ }
return baseCreate;
});
diff --git a/_baseFlatten.js b/_baseFlatten.js
index 79d0a9158..8488c552a 100644
--- a/_baseFlatten.js
+++ b/_baseFlatten.js
@@ -5,12 +5,12 @@ define(['./_arrayPush', './isArguments', './isArray', './isArrayLikeObject'], fu
*
* @private
* @param {Array} array The array to flatten.
- * @param {boolean} [isDeep] Specify a deep flatten.
+ * @param {number} depth The maximum recursion depth.
* @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
* @param {Array} [result=[]] The initial result value.
* @returns {Array} Returns the new flattened array.
*/
- function baseFlatten(array, isDeep, isStrict, result) {
+ function baseFlatten(array, depth, isStrict, result) {
result || (result = []);
var index = -1,
@@ -18,11 +18,11 @@ define(['./_arrayPush', './isArguments', './isArray', './isArrayLikeObject'], fu
while (++index < length) {
var value = array[index];
- if (isArrayLikeObject(value) &&
+ if (depth > 0 && isArrayLikeObject(value) &&
(isStrict || isArray(value) || isArguments(value))) {
- if (isDeep) {
+ if (depth > 1) {
// Recursively flatten arrays (susceptible to call stack limits).
- baseFlatten(value, isDeep, isStrict, result);
+ baseFlatten(value, depth - 1, isStrict, result);
} else {
arrayPush(result, value);
}
diff --git a/_baseGet.js b/_baseGet.js
index e0e224ad6..78b66a3c4 100644
--- a/_baseGet.js
+++ b/_baseGet.js
@@ -1,4 +1,4 @@
-define(['./_baseToPath', './_isKey'], function(baseToPath, isKey) {
+define(['./_baseCastPath', './_isKey'], function(baseCastPath, isKey) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -12,7 +12,7 @@ define(['./_baseToPath', './_isKey'], function(baseToPath, isKey) {
* @returns {*} Returns the resolved value.
*/
function baseGet(object, path) {
- path = isKey(path, object) ? [path + ''] : baseToPath(path);
+ path = isKey(path, object) ? [path + ''] : baseCastPath(path);
var index = 0,
length = path.length;
diff --git a/_baseIntersection.js b/_baseIntersection.js
index fff12ae74..a2b9ba583 100644
--- a/_baseIntersection.js
+++ b/_baseIntersection.js
@@ -40,11 +40,17 @@ define(['./_SetCache', './_arrayIncludes', './_arrayIncludesWith', './_arrayMap'
var value = array[index],
computed = iteratee ? iteratee(value) : value;
- if (!(seen ? cacheHas(seen, computed) : includes(result, computed, comparator))) {
+ if (!(seen
+ ? cacheHas(seen, computed)
+ : includes(result, computed, comparator)
+ )) {
var othIndex = othLength;
while (--othIndex) {
var cache = caches[othIndex];
- if (!(cache ? cacheHas(cache, computed) : includes(arrays[othIndex], computed, comparator))) {
+ if (!(cache
+ ? cacheHas(cache, computed)
+ : includes(arrays[othIndex], computed, comparator))
+ ) {
continue outer;
}
}
diff --git a/_baseInvoke.js b/_baseInvoke.js
index 2b6cd34a4..0869f868e 100644
--- a/_baseInvoke.js
+++ b/_baseInvoke.js
@@ -1,4 +1,4 @@
-define(['./_apply', './_baseToPath', './_isKey', './last', './_parent'], function(apply, baseToPath, isKey, last, parent) {
+define(['./_apply', './_baseCastPath', './_isKey', './last', './_parent'], function(apply, baseCastPath, isKey, last, parent) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -15,7 +15,7 @@ define(['./_apply', './_baseToPath', './_isKey', './last', './_parent'], functio
*/
function baseInvoke(object, path, args) {
if (!isKey(path, object)) {
- path = baseToPath(path);
+ path = baseCastPath(path);
object = parent(object, path);
path = last(path);
}
diff --git a/_baseKeys.js b/_baseKeys.js
index 6152f1e1b..10890112b 100644
--- a/_baseKeys.js
+++ b/_baseKeys.js
@@ -8,7 +8,6 @@ define([], function() {
* property of prototypes or treat sparse arrays as dense.
*
* @private
- * @type Function
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
*/
diff --git a/_baseMerge.js b/_baseMerge.js
index 084f7ce07..c53a5fc08 100644
--- a/_baseMerge.js
+++ b/_baseMerge.js
@@ -17,7 +17,10 @@ define(['./_Stack', './_arrayEach', './_assignMergeValue', './_baseMergeDeep', '
if (object === source) {
return;
}
- var props = (isArray(source) || isTypedArray(source)) ? undefined : keysIn(source);
+ var props = (isArray(source) || isTypedArray(source))
+ ? undefined
+ : keysIn(source);
+
arrayEach(props || source, function(srcValue, key) {
if (props) {
key = srcValue;
@@ -28,7 +31,10 @@ define(['./_Stack', './_arrayEach', './_assignMergeValue', './_baseMergeDeep', '
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
}
else {
- var newValue = customizer ? customizer(object[key], srcValue, (key + ''), object, source, stack) : undefined;
+ var newValue = customizer
+ ? customizer(object[key], srcValue, (key + ''), object, source, stack)
+ : undefined;
+
if (newValue === undefined) {
newValue = srcValue;
}
diff --git a/_baseMergeDeep.js b/_baseMergeDeep.js
index ecdd48a39..b581a8337 100644
--- a/_baseMergeDeep.js
+++ b/_baseMergeDeep.js
@@ -26,21 +26,24 @@ define(['./_assignMergeValue', './_baseClone', './_copyArray', './isArguments',
assignMergeValue(object, key, stacked);
return;
}
- var newValue = customizer ? customizer(objValue, srcValue, (key + ''), object, source, stack) : undefined,
- isCommon = newValue === undefined;
+ var newValue = customizer
+ ? customizer(objValue, srcValue, (key + ''), object, source, stack)
+ : undefined;
+
+ var isCommon = newValue === undefined;
if (isCommon) {
newValue = srcValue;
if (isArray(srcValue) || isTypedArray(srcValue)) {
if (isArray(objValue)) {
- newValue = srcIndex ? copyArray(objValue) : objValue;
+ newValue = objValue;
}
else if (isArrayLikeObject(objValue)) {
newValue = copyArray(objValue);
}
else {
isCommon = false;
- newValue = baseClone(srcValue);
+ newValue = baseClone(srcValue, true);
}
}
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
@@ -49,10 +52,10 @@ define(['./_assignMergeValue', './_baseClone', './_copyArray', './isArguments',
}
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
isCommon = false;
- newValue = baseClone(srcValue);
+ newValue = baseClone(srcValue, true);
}
else {
- newValue = srcIndex ? baseClone(objValue) : objValue;
+ newValue = objValue;
}
}
else {
diff --git a/_basePullAt.js b/_basePullAt.js
index c68033122..4475a6d0e 100644
--- a/_basePullAt.js
+++ b/_basePullAt.js
@@ -1,4 +1,4 @@
-define(['./_baseToPath', './_isIndex', './_isKey', './last', './_parent'], function(baseToPath, isIndex, isKey, last, parent) {
+define(['./_baseCastPath', './_isIndex', './_isKey', './last', './_parent'], function(baseCastPath, isIndex, isKey, last, parent) {
/** Used for built-in method references. */
var arrayProto = Array.prototype;
@@ -27,7 +27,7 @@ define(['./_baseToPath', './_isIndex', './_isKey', './last', './_parent'], funct
splice.call(array, index, 1);
}
else if (!isKey(index, array)) {
- var path = baseToPath(index),
+ var path = baseCastPath(index),
object = parent(array, path);
if (object != null) {
diff --git a/_baseSet.js b/_baseSet.js
index 241b10c52..274cb3cbe 100644
--- a/_baseSet.js
+++ b/_baseSet.js
@@ -1,4 +1,4 @@
-define(['./_assignValue', './_baseToPath', './_isIndex', './_isKey', './isObject'], function(assignValue, baseToPath, isIndex, isKey, isObject) {
+define(['./_assignValue', './_baseCastPath', './_isIndex', './_isKey', './isObject'], function(assignValue, baseCastPath, isIndex, isKey, isObject) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -14,7 +14,7 @@ define(['./_assignValue', './_baseToPath', './_isIndex', './_isKey', './isObject
* @returns {Object} Returns `object`.
*/
function baseSet(object, path, value, customizer) {
- path = isKey(path, object) ? [path + ''] : baseToPath(path);
+ path = isKey(path, object) ? [path + ''] : baseCastPath(path);
var index = -1,
length = path.length,
@@ -29,7 +29,9 @@ define(['./_assignValue', './_baseToPath', './_isIndex', './_isKey', './isObject
var objValue = nested[key];
newValue = customizer ? customizer(objValue, key, nested) : undefined;
if (newValue === undefined) {
- newValue = objValue == null ? (isIndex(path[index + 1]) ? [] : {}) : objValue;
+ newValue = objValue == null
+ ? (isIndex(path[index + 1]) ? [] : {})
+ : objValue;
}
}
assignValue(nested, key, newValue);
diff --git a/_baseToPath.js b/_baseToPath.js
deleted file mode 100644
index 66832e992..000000000
--- a/_baseToPath.js
+++ /dev/null
@@ -1,16 +0,0 @@
-define(['./isArray', './_stringToPath'], function(isArray, stringToPath) {
-
- /**
- * The base implementation of `_.toPath` which only converts `value` to a
- * path if it's not one.
- *
- * @private
- * @param {*} value The value to process.
- * @returns {Array} Returns the property path array.
- */
- function baseToPath(value) {
- return isArray(value) ? value : stringToPath(value);
- }
-
- return baseToPath;
-});
diff --git a/_baseUnset.js b/_baseUnset.js
index 3e874bd17..ff5bbf7a8 100644
--- a/_baseUnset.js
+++ b/_baseUnset.js
@@ -1,4 +1,4 @@
-define(['./_baseToPath', './has', './_isKey', './last', './_parent'], function(baseToPath, has, isKey, last, parent) {
+define(['./_baseCastPath', './has', './_isKey', './last', './_parent'], function(baseCastPath, has, isKey, last, parent) {
/**
* The base implementation of `_.unset`.
@@ -9,7 +9,7 @@ define(['./_baseToPath', './has', './_isKey', './last', './_parent'], function(b
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
*/
function baseUnset(object, path) {
- path = isKey(path, object) ? [path + ''] : baseToPath(path);
+ path = isKey(path, object) ? [path + ''] : baseCastPath(path);
object = parent(object, path);
var key = last(path);
return (object != null && has(object, key)) ? delete object[key] : true;
diff --git a/_cloneTypedArray.js b/_cloneTypedArray.js
index d59bc39ed..babb35974 100644
--- a/_cloneTypedArray.js
+++ b/_cloneTypedArray.js
@@ -9,10 +9,11 @@ define(['./_cloneArrayBuffer'], function(cloneArrayBuffer) {
* @returns {Object} Returns the cloned typed array.
*/
function cloneTypedArray(typedArray, isDeep) {
- var buffer = typedArray.buffer,
+ var arrayBuffer = typedArray.buffer,
+ buffer = isDeep ? cloneArrayBuffer(arrayBuffer) : arrayBuffer,
Ctor = typedArray.constructor;
- return new Ctor(isDeep ? cloneArrayBuffer(buffer) : buffer, typedArray.byteOffset, typedArray.length);
+ return new Ctor(buffer, typedArray.byteOffset, typedArray.length);
}
return cloneTypedArray;
diff --git a/_copyObjectWith.js b/_copyObjectWith.js
index c069fa444..d1b26d3a9 100644
--- a/_copyObjectWith.js
+++ b/_copyObjectWith.js
@@ -18,8 +18,11 @@ define(['./_assignValue'], function(assignValue) {
length = props.length;
while (++index < length) {
- var key = props[index],
- newValue = customizer ? customizer(object[key], source[key], key, object, source) : source[key];
+ var key = props[index];
+
+ var newValue = customizer
+ ? customizer(object[key], source[key], key, object, source)
+ : source[key];
assignValue(object, key, newValue);
}
diff --git a/_createAssigner.js b/_createAssigner.js
index 3ab332753..c7a515d10 100644
--- a/_createAssigner.js
+++ b/_createAssigner.js
@@ -17,7 +17,10 @@ define(['./_isIterateeCall', './rest'], function(isIterateeCall, rest) {
customizer = length > 1 ? sources[length - 1] : undefined,
guard = length > 2 ? sources[2] : undefined;
- customizer = typeof customizer == 'function' ? (length--, customizer) : undefined;
+ customizer = typeof customizer == 'function'
+ ? (length--, customizer)
+ : undefined;
+
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
customizer = length < 3 ? undefined : customizer;
length = 1;
diff --git a/_createCaseFirst.js b/_createCaseFirst.js
index 717069d7e..af5f546e8 100644
--- a/_createCaseFirst.js
+++ b/_createCaseFirst.js
@@ -26,8 +26,11 @@ define(['./_stringToArray', './toString'], function(stringToArray, toString) {
return function(string) {
string = toString(string);
- var strSymbols = reHasComplexSymbol.test(string) ? stringToArray(string) : undefined,
- chr = strSymbols ? strSymbols[0] : string.charAt(0),
+ var strSymbols = reHasComplexSymbol.test(string)
+ ? stringToArray(string)
+ : undefined;
+
+ var chr = strSymbols ? strSymbols[0] : string.charAt(0),
trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1);
return chr[methodName]() + trailing;
diff --git a/_createFlow.js b/_createFlow.js
index 997d91c7e..61f241b14 100644
--- a/_createFlow.js
+++ b/_createFlow.js
@@ -24,7 +24,7 @@ define(['./_LodashWrapper', './_baseFlatten', './_getData', './_getFuncName', '.
*/
function createFlow(fromRight) {
return rest(function(funcs) {
- funcs = baseFlatten(funcs);
+ funcs = baseFlatten(funcs, 1);
var length = funcs.length,
index = length,
@@ -49,7 +49,10 @@ define(['./_LodashWrapper', './_baseFlatten', './_getData', './_getFuncName', '.
var funcName = getFuncName(func),
data = funcName == 'wrapper' ? getData(func) : undefined;
- if (data && isLaziable(data[0]) && data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) && !data[4].length && data[9] == 1) {
+ if (data && isLaziable(data[0]) &&
+ data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) &&
+ !data[4].length && data[9] == 1
+ ) {
wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
} else {
wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func);
@@ -59,7 +62,8 @@ define(['./_LodashWrapper', './_baseFlatten', './_getData', './_getFuncName', '.
var args = arguments,
value = args[0];
- if (wrapper && args.length == 1 && isArray(value) && value.length >= LARGE_ARRAY_SIZE) {
+ if (wrapper && args.length == 1 &&
+ isArray(value) && value.length >= LARGE_ARRAY_SIZE) {
return wrapper.plant(value).value();
}
var index = 0,
diff --git a/_createHybridWrapper.js b/_createHybridWrapper.js
index 6947080f7..42e8025d0 100644
--- a/_createHybridWrapper.js
+++ b/_createHybridWrapper.js
@@ -57,7 +57,10 @@ define(['./_composeArgs', './_composeArgsRight', './_createCtorWrapper', './_cre
length -= argsHolders.length;
if (length < arity) {
- return createRecurryWrapper(func, bitmask, createHybridWrapper, placeholder, thisArg, args, argsHolders, argPos, ary, arity - length);
+ return createRecurryWrapper(
+ func, bitmask, createHybridWrapper, placeholder, thisArg, args,
+ argsHolders, argPos, ary, arity - length
+ );
}
}
var thisBinding = isBind ? thisArg : this,
diff --git a/_createOver.js b/_createOver.js
index 42e739769..ca834ba30 100644
--- a/_createOver.js
+++ b/_createOver.js
@@ -9,7 +9,7 @@ define(['./_apply', './_arrayMap', './_baseFlatten', './_baseIteratee', './rest'
*/
function createOver(arrayFunc) {
return rest(function(iteratees) {
- iteratees = arrayMap(baseFlatten(iteratees), baseIteratee);
+ iteratees = arrayMap(baseFlatten(iteratees, 1), baseIteratee);
return rest(function(args) {
var thisArg = this;
return arrayFunc(iteratees, function(iteratee) {
diff --git a/_createRecurryWrapper.js b/_createRecurryWrapper.js
index 5c37effb1..d1fc1e6a9 100644
--- a/_createRecurryWrapper.js
+++ b/_createRecurryWrapper.js
@@ -41,9 +41,12 @@ define(['./_copyArray', './_isLaziable', './_setData'], function(copyArray, isLa
if (!(bitmask & CURRY_BOUND_FLAG)) {
bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
}
- var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, arity],
- result = wrapFunc.apply(undefined, newData);
+ var newData = [
+ func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight,
+ newHoldersRight, newArgPos, ary, arity
+ ];
+ var result = wrapFunc.apply(undefined, newData);
if (isLaziable(func)) {
setData(result, newData);
}
diff --git a/_createWrapper.js b/_createWrapper.js
index 09299bf91..0be374386 100644
--- a/_createWrapper.js
+++ b/_createWrapper.js
@@ -62,8 +62,12 @@ define(['./_baseSetData', './_createBaseWrapper', './_createCurryWrapper', './_c
partials = holders = undefined;
}
- var data = isBindKey ? undefined : getData(func),
- newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity];
+ var data = isBindKey ? undefined : getData(func);
+
+ var newData = [
+ func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
+ argPos, ary, arity
+ ];
if (data) {
mergeData(newData, data);
diff --git a/_hasPath.js b/_hasPath.js
index 96e2647e4..7174a5687 100644
--- a/_hasPath.js
+++ b/_hasPath.js
@@ -1,4 +1,4 @@
-define(['./_baseToPath', './isArguments', './isArray', './_isIndex', './_isKey', './isLength', './isString', './last', './_parent'], function(baseToPath, isArguments, isArray, isIndex, isKey, isLength, isString, last, parent) {
+define(['./_baseCastPath', './isArguments', './isArray', './_isIndex', './_isKey', './isLength', './isString', './last', './_parent'], function(baseCastPath, isArguments, isArray, isIndex, isKey, isLength, isString, last, parent) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -18,7 +18,7 @@ define(['./_baseToPath', './isArguments', './isArray', './_isIndex', './_isKey',
}
var result = hasFunc(object, path);
if (!result && !isKey(path)) {
- path = baseToPath(path);
+ path = baseCastPath(path);
object = parent(object, path);
if (object != null) {
path = last(path);
diff --git a/_isKeyable.js b/_isKeyable.js
index f7a29ae90..0ed5cabce 100644
--- a/_isKeyable.js
+++ b/_isKeyable.js
@@ -10,7 +10,7 @@ define([], function() {
function isKeyable(value) {
var type = typeof value;
return type == 'number' || type == 'boolean' ||
- (type == 'string' && value !== '__proto__') || value == null;
+ (type == 'string' && value != '__proto__') || value == null;
}
return isKeyable;
diff --git a/_lazyValue.js b/_lazyValue.js
index 7e62ff3d3..2903bb0a0 100644
--- a/_lazyValue.js
+++ b/_lazyValue.js
@@ -34,7 +34,8 @@ define(['./_baseWrapperValue', './_getView', './isArray'], function(baseWrapperV
resIndex = 0,
takeCount = nativeMin(length, this.__takeCount__);
- if (!isArr || arrLength < LARGE_ARRAY_SIZE || (arrLength == length && takeCount == length)) {
+ if (!isArr || arrLength < LARGE_ARRAY_SIZE ||
+ (arrLength == length && takeCount == length)) {
return baseWrapperValue(array, this.__actions__);
}
var result = [];
diff --git a/_mapClear.js b/_mapClear.js
index 5a6a6d00f..4a469d237 100644
--- a/_mapClear.js
+++ b/_mapClear.js
@@ -8,7 +8,11 @@ define(['./_Hash', './_Map'], function(Hash, Map) {
* @memberOf MapCache
*/
function mapClear() {
- this.__data__ = { 'hash': new Hash, 'map': Map ? new Map : [], 'string': new Hash };
+ this.__data__ = {
+ 'hash': new Hash,
+ 'map': Map ? new Map : [],
+ 'string': new Hash
+ };
}
return mapClear;
diff --git a/_root.js b/_root.js
index 193f85a65..873cf275a 100644
--- a/_root.js
+++ b/_root.js
@@ -1,5 +1,8 @@
define(['./_checkGlobal'], function(checkGlobal) {
+ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
+ var undefined;
+
/** Used to determine if values are of the language type `Object`. */
var objectTypes = {
'function': true,
@@ -7,10 +10,14 @@ define(['./_checkGlobal'], function(checkGlobal) {
};
/** Detect free variable `exports`. */
- var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : null;
+ var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
+ ? exports
+ : undefined;
/** Detect free variable `module`. */
- var freeModule = (objectTypes[typeof module] && module && !module.nodeType) ? module : null;
+ var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
+ ? module
+ : undefined;
/** Detect free variable `global` from Node.js. */
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
@@ -30,7 +37,9 @@ define(['./_checkGlobal'], function(checkGlobal) {
* The `this` value is used if it's the global object to avoid Greasemonkey's
* restricted `window` object, otherwise the `window` object is used.
*/
- var root = freeGlobal || ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || freeSelf || thisGlobal || Function('return this')();
+ var root = freeGlobal ||
+ ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) ||
+ freeSelf || thisGlobal || Function('return this')();
return root;
});
diff --git a/_toFunction.js b/_toFunction.js
deleted file mode 100644
index 07d34f233..000000000
--- a/_toFunction.js
+++ /dev/null
@@ -1,15 +0,0 @@
-define(['./identity'], function(identity) {
-
- /**
- * Converts `value` to a function if it's not one.
- *
- * @private
- * @param {*} value The value to process.
- * @returns {Function} Returns the function.
- */
- function toFunction(value) {
- return typeof value == 'function' ? value : identity;
- }
-
- return toFunction;
-});
diff --git a/array.js b/array.js
index 6fb6328c7..da78f9d99 100644
--- a/array.js
+++ b/array.js
@@ -1,4 +1,4 @@
-define(['./chunk', './compact', './concat', './difference', './differenceBy', './differenceWith', './drop', './dropRight', './dropRightWhile', './dropWhile', './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'], function(chunk, compact, concat, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, 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) {
+define(['./chunk', './compact', './concat', './difference', './differenceBy', './differenceWith', './drop', './dropRight', './dropRightWhile', './dropWhile', './fill', './findIndex', './findLastIndex', './flatten', './flattenDeep', './flattenDepth', './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'], function(chunk, compact, concat, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, fill, findIndex, findLastIndex, flatten, flattenDeep, flattenDepth, 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) {
return {
'chunk': chunk,
'compact': compact,
@@ -15,6 +15,7 @@ define(['./chunk', './compact', './concat', './difference', './differenceBy', '.
'findLastIndex': findLastIndex,
'flatten': flatten,
'flattenDeep': flattenDeep,
+ 'flattenDepth': flattenDepth,
'fromPairs': fromPairs,
'head': head,
'indexOf': indexOf,
diff --git a/at.js b/at.js
index 7a858d051..8a9c7664e 100644
--- a/at.js
+++ b/at.js
@@ -21,7 +21,7 @@ define(['./_baseAt', './_baseFlatten', './rest'], function(baseAt, baseFlatten,
* // => ['a', 'c']
*/
var at = rest(function(object, paths) {
- return baseAt(object, baseFlatten(paths));
+ return baseAt(object, baseFlatten(paths, 1));
});
return at;
diff --git a/attempt.js b/attempt.js
index bef212c82..737f47881 100644
--- a/attempt.js
+++ b/attempt.js
@@ -1,4 +1,4 @@
-define(['./_apply', './isObject', './rest'], function(apply, isObject, rest) {
+define(['./_apply', './isError', './rest'], function(apply, isError, rest) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -27,7 +27,7 @@ define(['./_apply', './isObject', './rest'], function(apply, isObject, rest) {
try {
return apply(func, undefined, args);
} catch (e) {
- return isObject(e) ? e : new Error(e);
+ return isError(e) ? e : new Error(e);
}
});
diff --git a/bindAll.js b/bindAll.js
index 3b137b5f1..975b069bb 100644
--- a/bindAll.js
+++ b/bindAll.js
@@ -27,7 +27,7 @@ define(['./_arrayEach', './_baseFlatten', './bind', './rest'], function(arrayEac
* // => logs 'clicked docs' when clicked
*/
var bindAll = rest(function(object, methodNames) {
- arrayEach(baseFlatten(methodNames), function(key) {
+ arrayEach(baseFlatten(methodNames, 1), function(key) {
object[key] = bind(object[key], object);
});
return object;
diff --git a/castArray.js b/castArray.js
new file mode 100644
index 000000000..aa34bbe69
--- /dev/null
+++ b/castArray.js
@@ -0,0 +1,44 @@
+define(['./isArray'], function(isArray) {
+
+ /**
+ * Casts `value` as an array if it's not one.
+ *
+ * @static
+ * @memberOf _
+ * @category Lang
+ * @param {*} value The value to inspect.
+ * @returns {Array} Returns the cast array.
+ * @example
+ *
+ * _.castArray(1);
+ * // => [1]
+ *
+ * _.castArray({ 'a': 1 });
+ * // => [{ 'a': 1 }]
+ *
+ * _.castArray('abc');
+ * // => ['abc']
+ *
+ * _.castArray(null);
+ * // => [null]
+ *
+ * _.castArray(undefined);
+ * // => [undefined]
+ *
+ * _.castArray();
+ * // => []
+ *
+ * var array = [1, 2, 3];
+ * console.log(_.castArray(array) === array);
+ * // => true
+ */
+ function castArray() {
+ if (!arguments.length) {
+ return [];
+ }
+ var value = arguments[0];
+ return isArray(value) ? value : [value];
+ }
+
+ return castArray;
+});
diff --git a/concat.js b/concat.js
index be0148e6d..77c1a1398 100644
--- a/concat.js
+++ b/concat.js
@@ -25,7 +25,7 @@ define(['./_arrayConcat', './_baseFlatten', './isArray', './rest'], function(arr
if (!isArray(array)) {
array = array == null ? [] : [Object(array)];
}
- values = baseFlatten(values);
+ values = baseFlatten(values, 1);
return arrayConcat(array, values);
});
diff --git a/debounce.js b/debounce.js
index e5c183870..83a6df259 100644
--- a/debounce.js
+++ b/debounce.js
@@ -139,8 +139,10 @@ define(['./isObject', './now', './toNumber'], function(isObject, now, toNumber)
if (!lastCalled && !maxTimeoutId && !leading) {
lastCalled = stamp;
}
- var remaining = maxWait - (stamp - lastCalled),
- isCalled = remaining <= 0 || remaining > maxWait;
+ var remaining = maxWait - (stamp - lastCalled);
+
+ var isCalled = (remaining <= 0 || remaining > maxWait) &&
+ (leading || maxTimeoutId);
if (isCalled) {
if (maxTimeoutId) {
diff --git a/difference.js b/difference.js
index 33e0fb748..e567db511 100644
--- a/difference.js
+++ b/difference.js
@@ -18,7 +18,7 @@ define(['./_baseDifference', './_baseFlatten', './isArrayLikeObject', './rest'],
*/
var difference = rest(function(array, values) {
return isArrayLikeObject(array)
- ? baseDifference(array, baseFlatten(values, false, true))
+ ? baseDifference(array, baseFlatten(values, 1, true))
: [];
});
diff --git a/differenceBy.js b/differenceBy.js
index 6e78fa456..a3f81b30d 100644
--- a/differenceBy.js
+++ b/differenceBy.js
@@ -30,7 +30,7 @@ define(['./_baseDifference', './_baseFlatten', './_baseIteratee', './isArrayLike
iteratee = undefined;
}
return isArrayLikeObject(array)
- ? baseDifference(array, baseFlatten(values, false, true), baseIteratee(iteratee))
+ ? baseDifference(array, baseFlatten(values, 1, true), baseIteratee(iteratee))
: [];
});
diff --git a/differenceWith.js b/differenceWith.js
index 5df03fc1d..bfa94a9a0 100644
--- a/differenceWith.js
+++ b/differenceWith.js
@@ -28,7 +28,7 @@ define(['./_baseDifference', './_baseFlatten', './isArrayLikeObject', './last',
comparator = undefined;
}
return isArrayLikeObject(array)
- ? baseDifference(array, baseFlatten(values, false, true), undefined, comparator)
+ ? baseDifference(array, baseFlatten(values, 1, true), undefined, comparator)
: [];
});
diff --git a/flatMap.js b/flatMap.js
index 766199337..e1cd819ed 100644
--- a/flatMap.js
+++ b/flatMap.js
@@ -21,7 +21,7 @@ define(['./_baseFlatten', './map'], function(baseFlatten, map) {
* // => [1, 1, 2, 2]
*/
function flatMap(collection, iteratee) {
- return baseFlatten(map(collection, iteratee));
+ return baseFlatten(map(collection, iteratee), 1);
}
return flatMap;
diff --git a/flatten.js b/flatten.js
index e58f913bc..835e9d619 100644
--- a/flatten.js
+++ b/flatten.js
@@ -1,7 +1,7 @@
define(['./_baseFlatten'], function(baseFlatten) {
/**
- * Flattens `array` a single level.
+ * Flattens `array` a single level deep.
*
* @static
* @memberOf _
@@ -10,12 +10,12 @@ define(['./_baseFlatten'], function(baseFlatten) {
* @returns {Array} Returns the new flattened array.
* @example
*
- * _.flatten([1, [2, 3, [4]]]);
- * // => [1, 2, 3, [4]]
+ * _.flatten([1, [2, [3, [4]], 5]]);
+ * // => [1, 2, [3, [4]], 5]
*/
function flatten(array) {
var length = array ? array.length : 0;
- return length ? baseFlatten(array) : [];
+ return length ? baseFlatten(array, 1) : [];
}
return flatten;
diff --git a/flattenDeep.js b/flattenDeep.js
index ebbd3fcda..cb6a9632d 100644
--- a/flattenDeep.js
+++ b/flattenDeep.js
@@ -1,21 +1,24 @@
define(['./_baseFlatten'], function(baseFlatten) {
+ /** Used as references for various `Number` constants. */
+ var INFINITY = 1 / 0;
+
/**
- * This method is like `_.flatten` except that it recursively flattens `array`.
+ * Recursively flattens `array`.
*
* @static
* @memberOf _
* @category Array
- * @param {Array} array The array to recursively flatten.
+ * @param {Array} array The array to flatten.
* @returns {Array} Returns the new flattened array.
* @example
*
- * _.flattenDeep([1, [2, 3, [4]]]);
- * // => [1, 2, 3, 4]
+ * _.flattenDeep([1, [2, [3, [4]], 5]]);
+ * // => [1, 2, 3, 4, 5]
*/
function flattenDeep(array) {
var length = array ? array.length : 0;
- return length ? baseFlatten(array, true) : [];
+ return length ? baseFlatten(array, INFINITY) : [];
}
return flattenDeep;
diff --git a/flattenDepth.js b/flattenDepth.js
new file mode 100644
index 000000000..218c8e415
--- /dev/null
+++ b/flattenDepth.js
@@ -0,0 +1,35 @@
+define(['./_baseFlatten', './toInteger'], function(baseFlatten, toInteger) {
+
+ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
+ var undefined;
+
+ /**
+ * Recursively flatten `array` up to `depth` times.
+ *
+ * @static
+ * @memberOf _
+ * @category Array
+ * @param {Array} array The array to flatten.
+ * @param {number} [depth=1] The maximum recursion depth.
+ * @returns {Array} Returns the new flattened array.
+ * @example
+ *
+ * var array = [1, [2, [3, [4]], 5]];
+ *
+ * _.flattenDepth(array, 1);
+ * // => [1, 2, [3, [4]], 5]
+ *
+ * _.flattenDepth(array, 2);
+ * // => [1, 2, 3, [4], 5]
+ */
+ function flattenDepth(array, depth) {
+ var length = array ? array.length : 0;
+ if (!length) {
+ return [];
+ }
+ depth = depth === undefined ? 1 : toInteger(depth);
+ return baseFlatten(array, depth);
+ }
+
+ return flattenDepth;
+});
diff --git a/forEach.js b/forEach.js
index da1867cc9..cf14f9b4d 100644
--- a/forEach.js
+++ b/forEach.js
@@ -1,4 +1,4 @@
-define(['./_arrayEach', './_baseEach', './isArray', './_toFunction'], function(arrayEach, baseEach, isArray, toFunction) {
+define(['./_arrayEach', './_baseCastFunction', './_baseEach', './isArray'], function(arrayEach, baseCastFunction, baseEach, isArray) {
/**
* Iterates over elements of `collection` invoking `iteratee` for each element.
@@ -31,7 +31,7 @@ define(['./_arrayEach', './_baseEach', './isArray', './_toFunction'], function(a
function forEach(collection, iteratee) {
return (typeof iteratee == 'function' && isArray(collection))
? arrayEach(collection, iteratee)
- : baseEach(collection, toFunction(iteratee));
+ : baseEach(collection, baseCastFunction(iteratee));
}
return forEach;
diff --git a/forEachRight.js b/forEachRight.js
index 4123efaed..b9beb02bb 100644
--- a/forEachRight.js
+++ b/forEachRight.js
@@ -1,4 +1,4 @@
-define(['./_arrayEachRight', './_baseEachRight', './isArray', './_toFunction'], function(arrayEachRight, baseEachRight, isArray, toFunction) {
+define(['./_arrayEachRight', './_baseCastFunction', './_baseEachRight', './isArray'], function(arrayEachRight, baseCastFunction, baseEachRight, isArray) {
/**
* This method is like `_.forEach` except that it iterates over elements of
@@ -21,7 +21,7 @@ define(['./_arrayEachRight', './_baseEachRight', './isArray', './_toFunction'],
function forEachRight(collection, iteratee) {
return (typeof iteratee == 'function' && isArray(collection))
? arrayEachRight(collection, iteratee)
- : baseEachRight(collection, toFunction(iteratee));
+ : baseEachRight(collection, baseCastFunction(iteratee));
}
return forEachRight;
diff --git a/forIn.js b/forIn.js
index d447f5a22..25ab15625 100644
--- a/forIn.js
+++ b/forIn.js
@@ -1,4 +1,4 @@
-define(['./_baseFor', './keysIn', './_toFunction'], function(baseFor, keysIn, toFunction) {
+define(['./_baseCastFunction', './_baseFor', './keysIn'], function(baseCastFunction, baseFor, keysIn) {
/**
* Iterates over own and inherited enumerable properties of an object invoking
@@ -27,7 +27,9 @@ define(['./_baseFor', './keysIn', './_toFunction'], function(baseFor, keysIn, to
* // => logs 'a', 'b', then 'c' (iteration order is not guaranteed)
*/
function forIn(object, iteratee) {
- return object == null ? object : baseFor(object, toFunction(iteratee), keysIn);
+ return object == null
+ ? object
+ : baseFor(object, baseCastFunction(iteratee), keysIn);
}
return forIn;
diff --git a/forInRight.js b/forInRight.js
index e961ae670..d946264e2 100644
--- a/forInRight.js
+++ b/forInRight.js
@@ -1,4 +1,4 @@
-define(['./_baseForRight', './keysIn', './_toFunction'], function(baseForRight, keysIn, toFunction) {
+define(['./_baseCastFunction', './_baseForRight', './keysIn'], function(baseCastFunction, baseForRight, keysIn) {
/**
* This method is like `_.forIn` except that it iterates over properties of
@@ -25,7 +25,9 @@ define(['./_baseForRight', './keysIn', './_toFunction'], function(baseForRight,
* // => logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'
*/
function forInRight(object, iteratee) {
- return object == null ? object : baseForRight(object, toFunction(iteratee), keysIn);
+ return object == null
+ ? object
+ : baseForRight(object, baseCastFunction(iteratee), keysIn);
}
return forInRight;
diff --git a/forOwn.js b/forOwn.js
index 96d6f477d..be1efd512 100644
--- a/forOwn.js
+++ b/forOwn.js
@@ -1,4 +1,4 @@
-define(['./_baseForOwn', './_toFunction'], function(baseForOwn, toFunction) {
+define(['./_baseCastFunction', './_baseForOwn'], function(baseCastFunction, baseForOwn) {
/**
* Iterates over own enumerable properties of an object invoking `iteratee`
@@ -27,7 +27,7 @@ define(['./_baseForOwn', './_toFunction'], function(baseForOwn, toFunction) {
* // => logs 'a' then 'b' (iteration order is not guaranteed)
*/
function forOwn(object, iteratee) {
- return object && baseForOwn(object, toFunction(iteratee));
+ return object && baseForOwn(object, baseCastFunction(iteratee));
}
return forOwn;
diff --git a/forOwnRight.js b/forOwnRight.js
index ef995a11c..4c0d565e6 100644
--- a/forOwnRight.js
+++ b/forOwnRight.js
@@ -1,4 +1,4 @@
-define(['./_baseForOwnRight', './_toFunction'], function(baseForOwnRight, toFunction) {
+define(['./_baseCastFunction', './_baseForOwnRight'], function(baseCastFunction, baseForOwnRight) {
/**
* This method is like `_.forOwn` except that it iterates over properties of
@@ -25,7 +25,7 @@ define(['./_baseForOwnRight', './_toFunction'], function(baseForOwnRight, toFunc
* // => logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'
*/
function forOwnRight(object, iteratee) {
- return object && baseForOwnRight(object, toFunction(iteratee));
+ return object && baseForOwnRight(object, baseCastFunction(iteratee));
}
return forOwnRight;
diff --git a/intersection.js b/intersection.js
index e955cfec8..47b3a0ae1 100644
--- a/intersection.js
+++ b/intersection.js
@@ -1,4 +1,4 @@
-define(['./_arrayMap', './_baseIntersection', './rest', './_toArrayLikeObject'], function(arrayMap, baseIntersection, rest, toArrayLikeObject) {
+define(['./_arrayMap', './_baseCastArrayLikeObject', './_baseIntersection', './rest'], function(arrayMap, baseCastArrayLikeObject, baseIntersection, rest) {
/**
* Creates an array of unique values that are included in all given arrays
@@ -16,7 +16,7 @@ define(['./_arrayMap', './_baseIntersection', './rest', './_toArrayLikeObject'],
* // => [2]
*/
var intersection = rest(function(arrays) {
- var mapped = arrayMap(arrays, toArrayLikeObject);
+ var mapped = arrayMap(arrays, baseCastArrayLikeObject);
return (mapped.length && mapped[0] === arrays[0])
? baseIntersection(mapped)
: [];
diff --git a/intersectionBy.js b/intersectionBy.js
index 2a5eea52f..b5e1a3ce0 100644
--- a/intersectionBy.js
+++ b/intersectionBy.js
@@ -1,4 +1,4 @@
-define(['./_arrayMap', './_baseIntersection', './_baseIteratee', './last', './rest', './_toArrayLikeObject'], function(arrayMap, baseIntersection, baseIteratee, last, rest, toArrayLikeObject) {
+define(['./_arrayMap', './_baseCastArrayLikeObject', './_baseIntersection', './_baseIteratee', './last', './rest'], function(arrayMap, baseCastArrayLikeObject, baseIntersection, baseIteratee, last, rest) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -25,7 +25,7 @@ define(['./_arrayMap', './_baseIntersection', './_baseIteratee', './last', './re
*/
var intersectionBy = rest(function(arrays) {
var iteratee = last(arrays),
- mapped = arrayMap(arrays, toArrayLikeObject);
+ mapped = arrayMap(arrays, baseCastArrayLikeObject);
if (iteratee === last(mapped)) {
iteratee = undefined;
diff --git a/intersectionWith.js b/intersectionWith.js
index 9a64a87e9..108695c33 100644
--- a/intersectionWith.js
+++ b/intersectionWith.js
@@ -1,4 +1,4 @@
-define(['./_arrayMap', './_baseIntersection', './last', './rest', './_toArrayLikeObject'], function(arrayMap, baseIntersection, last, rest, toArrayLikeObject) {
+define(['./_arrayMap', './_baseCastArrayLikeObject', './_baseIntersection', './last', './rest'], function(arrayMap, baseCastArrayLikeObject, baseIntersection, last, rest) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -24,7 +24,7 @@ define(['./_arrayMap', './_baseIntersection', './last', './rest', './_toArrayLik
*/
var intersectionWith = rest(function(arrays) {
var comparator = last(arrays),
- mapped = arrayMap(arrays, toArrayLikeObject);
+ mapped = arrayMap(arrays, baseCastArrayLikeObject);
if (comparator === last(mapped)) {
comparator = undefined;
diff --git a/isArray.js b/isArray.js
index a27d86820..c1e74b1a4 100644
--- a/isArray.js
+++ b/isArray.js
@@ -5,7 +5,7 @@ define([], function() {
*
* @static
* @memberOf _
- * @type Function
+ * @type {Function}
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
diff --git a/isArrayBuffer.js b/isArrayBuffer.js
index 03eabe254..a7bc87511 100644
--- a/isArrayBuffer.js
+++ b/isArrayBuffer.js
@@ -16,7 +16,6 @@ define(['./isObjectLike'], function(isObjectLike) {
*
* @static
* @memberOf _
- * @type Function
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
diff --git a/isArrayLike.js b/isArrayLike.js
index dc803c03f..c076fa403 100644
--- a/isArrayLike.js
+++ b/isArrayLike.js
@@ -7,7 +7,6 @@ define(['./_getLength', './isFunction', './isLength'], function(getLength, isFun
*
* @static
* @memberOf _
- * @type Function
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
diff --git a/isArrayLikeObject.js b/isArrayLikeObject.js
index 31f66167c..59664b58b 100644
--- a/isArrayLikeObject.js
+++ b/isArrayLikeObject.js
@@ -6,7 +6,6 @@ define(['./isArrayLike', './isObjectLike'], function(isArrayLike, isObjectLike)
*
* @static
* @memberOf _
- * @type Function
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array-like object, else `false`.
diff --git a/isBuffer.js b/isBuffer.js
index af0aef0b9..2b5938c21 100644
--- a/isBuffer.js
+++ b/isBuffer.js
@@ -10,13 +10,19 @@ define(['./constant', './_root'], function(constant, root) {
};
/** Detect free variable `exports`. */
- var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : null;
+ var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
+ ? exports
+ : undefined;
/** Detect free variable `module`. */
- var freeModule = (objectTypes[typeof module] && module && !module.nodeType) ? module : null;
+ var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
+ ? module
+ : undefined;
/** Detect the popular CommonJS extension `module.exports`. */
- var moduleExports = (freeModule && freeModule.exports === freeExports) ? freeExports : null;
+ var moduleExports = (freeModule && freeModule.exports === freeExports)
+ ? freeExports
+ : undefined;
/** Built-in value references. */
var Buffer = moduleExports ? root.Buffer : undefined;
diff --git a/isEmpty.js b/isEmpty.js
index ef45c34c7..efcbba936 100644
--- a/isEmpty.js
+++ b/isEmpty.js
@@ -35,7 +35,8 @@ define(['./isArguments', './isArray', './isArrayLike', './isFunction', './isStri
*/
function isEmpty(value) {
if (isArrayLike(value) &&
- (isArray(value) || isString(value) || isFunction(value.splice) || isArguments(value))) {
+ (isArray(value) || isString(value) ||
+ isFunction(value.splice) || isArguments(value))) {
return !value.length;
}
for (var key in value) {
diff --git a/isEqualWith.js b/isEqualWith.js
index b0fcd2f18..8a6f018c9 100644
--- a/isEqualWith.js
+++ b/isEqualWith.js
@@ -4,10 +4,10 @@ define(['./_baseIsEqual'], function(baseIsEqual) {
var undefined;
/**
- * This method is like `_.isEqual` except that it accepts `customizer` which is
- * invoked to compare values. If `customizer` returns `undefined` comparisons are
- * handled by the method instead. The `customizer` is invoked with up to six arguments:
- * (objValue, othValue [, index|key, object, other, stack]).
+ * This method is like `_.isEqual` except that it accepts `customizer` which
+ * is invoked to compare values. If `customizer` returns `undefined` comparisons
+ * are handled by the method instead. The `customizer` is invoked with up to
+ * six arguments: (objValue, othValue [, index|key, object, other, stack]).
*
* @static
* @memberOf _
diff --git a/isError.js b/isError.js
index e0f46f04b..0ef064984 100644
--- a/isError.js
+++ b/isError.js
@@ -30,8 +30,12 @@ define(['./isObjectLike'], function(isObjectLike) {
* // => false
*/
function isError(value) {
- return isObjectLike(value) &&
- typeof value.message == 'string' && objectToString.call(value) == errorTag;
+ if (!isObjectLike(value)) {
+ return false;
+ }
+ var Ctor = value.constructor;
+ return (objectToString.call(value) == errorTag) ||
+ (typeof Ctor == 'function' && objectToString.call(Ctor.prototype) == errorTag);
}
return isError;
diff --git a/isLength.js b/isLength.js
index d23408916..836e56f35 100644
--- a/isLength.js
+++ b/isLength.js
@@ -28,7 +28,8 @@ define([], function() {
* // => false
*/
function isLength(value) {
- return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
+ return typeof value == 'number' &&
+ value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
}
return isLength;
diff --git a/isMatch.js b/isMatch.js
index 0dcbf5f30..2d0a2f714 100644
--- a/isMatch.js
+++ b/isMatch.js
@@ -1,8 +1,9 @@
define(['./_baseIsMatch', './_getMatchData'], function(baseIsMatch, getMatchData) {
/**
- * Performs a deep comparison between `object` and `source` to determine if
- * `object` contains equivalent property values.
+ * Performs a partial deep comparison between `object` and `source` to
+ * determine if `object` contains equivalent property values. This method is
+ * equivalent to a `_.matches` function when `source` is partially applied.
*
* **Note:** This method supports comparing the same values as `_.isEqual`.
*
diff --git a/isPlainObject.js b/isPlainObject.js
index d8357978e..e677fb177 100644
--- a/isPlainObject.js
+++ b/isPlainObject.js
@@ -49,7 +49,8 @@ define(['./_isHostObject', './isObjectLike'], function(isHostObject, isObjectLik
* // => true
*/
function isPlainObject(value) {
- if (!isObjectLike(value) || objectToString.call(value) != objectTag || isHostObject(value)) {
+ if (!isObjectLike(value) ||
+ objectToString.call(value) != objectTag || isHostObject(value)) {
return false;
}
var proto = objectProto;
diff --git a/isTypedArray.js b/isTypedArray.js
index 108042111..df4476057 100644
--- a/isTypedArray.js
+++ b/isTypedArray.js
@@ -67,7 +67,8 @@ define(['./isLength', './isObjectLike'], function(isLength, isObjectLike) {
* // => false
*/
function isTypedArray(value) {
- return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
+ return isObjectLike(value) &&
+ isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
}
return isTypedArray;
diff --git a/iteratee.js b/iteratee.js
index 8c23415d9..cea5c33e2 100644
--- a/iteratee.js
+++ b/iteratee.js
@@ -4,7 +4,8 @@ define(['./_baseClone', './_baseIteratee'], function(baseClone, baseIteratee) {
* Creates a function that invokes `func` with the arguments of the created
* function. If `func` is a property name the created callback returns the
* property value for a given element. If `func` is an object the created
- * callback returns `true` for elements that contain the equivalent object properties, otherwise it returns `false`.
+ * callback returns `true` for elements that contain the equivalent object
+ * properties, otherwise it returns `false`.
*
* @static
* @memberOf _
diff --git a/lang.js b/lang.js
index 7933e4931..c300215c4 100644
--- a/lang.js
+++ b/lang.js
@@ -1,5 +1,6 @@
-define(['./clone', './cloneDeep', './cloneDeepWith', './cloneWith', './eq', './gt', './gte', './isArguments', './isArray', './isArrayBuffer', './isArrayLike', './isArrayLikeObject', './isBoolean', './isBuffer', './isDate', './isElement', './isEmpty', './isEqual', './isEqualWith', './isError', './isFinite', './isFunction', './isInteger', './isLength', './isMap', './isMatch', './isMatchWith', './isNaN', './isNative', './isNil', './isNull', './isNumber', './isObject', './isObjectLike', './isPlainObject', './isRegExp', './isSafeInteger', './isSet', './isString', './isSymbol', './isTypedArray', './isUndefined', './isWeakMap', './isWeakSet', './lt', './lte', './toArray', './toInteger', './toLength', './toNumber', './toPlainObject', './toSafeInteger', './toString'], function(clone, cloneDeep, cloneDeepWith, cloneWith, eq, gt, gte, isArguments, isArray, isArrayBuffer, isArrayLike, isArrayLikeObject, isBoolean, isBuffer, isDate, isElement, isEmpty, isEqual, isEqualWith, isError, isFinite, isFunction, isInteger, isLength, isMap, isMatch, isMatchWith, isNaN, isNative, isNil, isNull, isNumber, isObject, isObjectLike, isPlainObject, isRegExp, isSafeInteger, isSet, isString, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet, lt, lte, toArray, toInteger, toLength, toNumber, toPlainObject, toSafeInteger, toString) {
+define(['./castArray', './clone', './cloneDeep', './cloneDeepWith', './cloneWith', './eq', './gt', './gte', './isArguments', './isArray', './isArrayBuffer', './isArrayLike', './isArrayLikeObject', './isBoolean', './isBuffer', './isDate', './isElement', './isEmpty', './isEqual', './isEqualWith', './isError', './isFinite', './isFunction', './isInteger', './isLength', './isMap', './isMatch', './isMatchWith', './isNaN', './isNative', './isNil', './isNull', './isNumber', './isObject', './isObjectLike', './isPlainObject', './isRegExp', './isSafeInteger', './isSet', './isString', './isSymbol', './isTypedArray', './isUndefined', './isWeakMap', './isWeakSet', './lt', './lte', './toArray', './toInteger', './toLength', './toNumber', './toPlainObject', './toSafeInteger', './toString'], function(castArray, clone, cloneDeep, cloneDeepWith, cloneWith, eq, gt, gte, isArguments, isArray, isArrayBuffer, isArrayLike, isArrayLikeObject, isBoolean, isBuffer, isDate, isElement, isEmpty, isEqual, isEqualWith, isError, isFinite, isFunction, isInteger, isLength, isMap, isMatch, isMatchWith, isNaN, isNative, isNil, isNull, isNumber, isObject, isObjectLike, isPlainObject, isRegExp, isSafeInteger, isSet, isString, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet, lt, lte, toArray, toInteger, toLength, toNumber, toPlainObject, toSafeInteger, toString) {
return {
+ 'castArray': castArray,
'clone': clone,
'cloneDeep': cloneDeep,
'cloneDeepWith': cloneDeepWith,
diff --git a/main.js b/main.js
index 65803e259..51065033a 100644
--- a/main.js
+++ b/main.js
@@ -1,6 +1,6 @@
/**
* @license
- * lodash 4.3.0 (Custom Build)
+ * lodash 4.4.0 (Custom Build)
* Build: `lodash exports="amd" -d -o ./main.js`
* Copyright 2012-2016 The Dojo Foundation
* Based on Underscore.js 1.8.3
@@ -13,7 +13,7 @@
var undefined;
/** Used as the semantic version number. */
- var VERSION = '4.3.0';
+ var VERSION = '4.4.0';
/** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1,
@@ -335,10 +335,19 @@
freeParseInt = parseInt;
/** Detect free variable `exports`. */
- var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType) ? exports : null;
+ var freeExports = (objectTypes[typeof exports] && exports && !exports.nodeType)
+ ? exports
+ : undefined;
/** Detect free variable `module`. */
- var freeModule = (objectTypes[typeof module] && module && !module.nodeType) ? module : null;
+ var freeModule = (objectTypes[typeof module] && module && !module.nodeType)
+ ? module
+ : undefined;
+
+ /** Detect the popular CommonJS extension `module.exports`. */
+ var moduleExports = (freeModule && freeModule.exports === freeExports)
+ ? freeExports
+ : undefined;
/** Detect free variable `global` from Node.js. */
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global);
@@ -349,9 +358,6 @@
/** Detect free variable `window`. */
var freeWindow = checkGlobal(objectTypes[typeof window] && window);
- /** Detect the popular CommonJS extension `module.exports`. */
- var moduleExports = (freeModule && freeModule.exports === freeExports) ? freeExports : null;
-
/** Detect `this` as the global object. */
var thisGlobal = checkGlobal(objectTypes[typeof this] && this);
@@ -361,7 +367,9 @@
* The `this` value is used if it's the global object to avoid Greasemonkey's
* restricted `window` object, otherwise the `window` object is used.
*/
- var root = freeGlobal || ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) || freeSelf || thisGlobal || Function('return this')();
+ var root = freeGlobal ||
+ ((freeWindow !== (thisGlobal && thisGlobal.window)) && freeWindow) ||
+ freeSelf || thisGlobal || Function('return this')();
/*--------------------------------------------------------------------------*/
@@ -1316,6 +1324,7 @@
getPrototypeOf = Object.getPrototypeOf,
getOwnPropertySymbols = Object.getOwnPropertySymbols,
iteratorSymbol = typeof (iteratorSymbol = Symbol && Symbol.iterator) == 'symbol' ? iteratorSymbol : undefined,
+ objectCreate = Object.create,
propertyIsEnumerable = objectProto.propertyIsEnumerable,
setTimeout = context.setTimeout,
splice = arrayProto.splice;
@@ -1395,28 +1404,28 @@
* `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
*
* The chainable wrapper methods are:
- * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`,
- * `at`, `before`, `bind`, `bindAll`, `bindKey`, `chain`, `chunk`, `commit`,
- * `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, `curry`,
- * `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, `difference`,
+ * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
+ * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
+ * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
+ * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, `difference`,
* `differenceBy`, `differenceWith`, `drop`, `dropRight`, `dropRightWhile`,
- * `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flip`, `flow`,
- * `flowRight`, `fromPairs`, `functions`, `functionsIn`, `groupBy`, `initial`,
- * `intersection`, `intersectionBy`, `intersectionWith`, `invert`, `invertBy`,
- * `invokeMap`, `iteratee`, `keyBy`, `keys`, `keysIn`, `map`, `mapKeys`,
- * `mapValues`, `matches`, `matchesProperty`, `memoize`, `merge`, `mergeWith`,
- * `method`, `methodOf`, `mixin`, `negate`, `nthArg`, `omit`, `omitBy`, `once`,
- * `orderBy`, `over`, `overArgs`, `overEvery`, `overSome`, `partial`,
- * `partialRight`, `partition`, `pick`, `pickBy`, `plant`, `property`,
- * `propertyOf`, `pull`, `pullAll`, `pullAllBy`, `pullAt`, `push`, `range`,
- * `rangeRight`, `rearg`, `reject`, `remove`, `rest`, `reverse`, `sampleSize`,
- * `set`, `setWith`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `spread`,
- * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`,
- * `thru`, `toArray`, `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`,
- * `transform`, `unary`, `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`,
- * `uniqWith`, `unset`, `unshift`, `unzip`, `unzipWith`, `values`, `valuesIn`,
- * `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, `zipObject`,
- * `zipObjectDeep`, and `zipWith`
+ * `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flattenDepth`,
+ * `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, `functionsIn`,
+ * `groupBy`, `initial`, `intersection`, `intersectionBy`, `intersectionWith`,
+ * `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, `keys`, `keysIn`,
+ * `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, `memoize`,
+ * `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, `nthArg`,
+ * `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, `overEvery`,
+ * `overSome`, `partial`, `partialRight`, `partition`, `pick`, `pickBy`, `plant`,
+ * `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, `pullAt`, `push`,
+ * `range`, `rangeRight`, `rearg`, `reject`, `remove`, `rest`, `reverse`,
+ * `sampleSize`, `set`, `setWith`, `shuffle`, `slice`, `sort`, `sortBy`,
+ * `splice`, `spread`, `tail`, `take`, `takeRight`, `takeRightWhile`,
+ * `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, `toPairs`, `toPairsIn`,
+ * `toPath`, `toPlainObject`, `transform`, `unary`, `union`, `unionBy`,
+ * `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, `unshift`, `unzip`,
+ * `unzipWith`, `values`, `valuesIn`, `without`, `wrap`, `xor`, `xorBy`,
+ * `xorWith`, `zip`, `zipObject`, `zipObjectDeep`, and `zipWith`
*
* The wrapper methods that are **not** chainable by default are:
* `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
@@ -1510,7 +1519,7 @@
*
* @static
* @memberOf _
- * @type Object
+ * @type {Object}
*/
lodash.templateSettings = {
@@ -1518,7 +1527,7 @@
* Used to detect `data` property values to be HTML-escaped.
*
* @memberOf _.templateSettings
- * @type RegExp
+ * @type {RegExp}
*/
'escape': reEscape,
@@ -1526,7 +1535,7 @@
* Used to detect code to be evaluated.
*
* @memberOf _.templateSettings
- * @type RegExp
+ * @type {RegExp}
*/
'evaluate': reEvaluate,
@@ -1534,7 +1543,7 @@
* Used to detect `data` property values to inject.
*
* @memberOf _.templateSettings
- * @type RegExp
+ * @type {RegExp}
*/
'interpolate': reInterpolate,
@@ -1542,7 +1551,7 @@
* Used to reference the data object in the template text.
*
* @memberOf _.templateSettings
- * @type string
+ * @type {string}
*/
'variable': '',
@@ -1550,7 +1559,7 @@
* Used to import variables into the compiled template.
*
* @memberOf _.templateSettings
- * @type Object
+ * @type {Object}
*/
'imports': {
@@ -1558,7 +1567,7 @@
* A reference to the `lodash` function.
*
* @memberOf _.templateSettings.imports
- * @type Function
+ * @type {Function}
*/
'_': lodash
}
@@ -1570,6 +1579,7 @@
* Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
*
* @private
+ * @constructor
* @param {*} value The value to wrap.
*/
function LazyWrapper(value) {
@@ -1645,7 +1655,8 @@
resIndex = 0,
takeCount = nativeMin(length, this.__takeCount__);
- if (!isArr || arrLength < LARGE_ARRAY_SIZE || (arrLength == length && takeCount == length)) {
+ if (!isArr || arrLength < LARGE_ARRAY_SIZE ||
+ (arrLength == length && takeCount == length)) {
return baseWrapperValue(array, this.__actions__);
}
var result = [];
@@ -1684,6 +1695,7 @@
* Creates an hash object.
*
* @private
+ * @constructor
* @returns {Object} Returns the new hash object.
*/
function Hash() {}
@@ -1746,6 +1758,7 @@
* Creates a map cache object to store key-value pairs.
*
* @private
+ * @constructor
* @param {Array} [values] The values to cache.
*/
function MapCache(values) {
@@ -1767,7 +1780,11 @@
* @memberOf MapCache
*/
function mapClear() {
- this.__data__ = { 'hash': new Hash, 'map': Map ? new Map : [], 'string': new Hash };
+ this.__data__ = {
+ 'hash': new Hash,
+ 'map': Map ? new Map : [],
+ 'string': new Hash
+ };
}
/**
@@ -1850,6 +1867,7 @@
* Creates a set cache object to store unique values.
*
* @private
+ * @constructor
* @param {Array} [values] The values to cache.
*/
function SetCache(values) {
@@ -1908,6 +1926,7 @@
* Creates a stack cache object to store key-value pairs.
*
* @private
+ * @constructor
* @param {Array} [values] The values to cache.
*/
function Stack(values) {
@@ -2199,6 +2218,39 @@
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} Returns the 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 {Array} Returns the array-like object.
+ */
+ function baseCastFunction(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 baseCastPath(value) {
+ return isArray(value) ? value : stringToPath(value);
+ }
+
/**
* The base implementation of `_.clamp` which doesn't coerce arguments to numbers.
*
@@ -2323,17 +2375,9 @@
* @param {Object} prototype The object to inherit from.
* @returns {Object} Returns the new object.
*/
- var baseCreate = (function() {
- function object() {}
- return function(prototype) {
- if (isObject(prototype)) {
- object.prototype = prototype;
- var result = new object;
- object.prototype = undefined;
- }
- return result || {};
- };
- }());
+ function baseCreate(proto) {
+ return isObject(proto) ? objectCreate(proto) : {};
+ }
/**
* The base implementation of `_.delay` and `_.defer` which accepts an array
@@ -2495,12 +2539,12 @@
*
* @private
* @param {Array} array The array to flatten.
- * @param {boolean} [isDeep] Specify a deep flatten.
+ * @param {number} depth The maximum recursion depth.
* @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
* @param {Array} [result=[]] The initial result value.
* @returns {Array} Returns the new flattened array.
*/
- function baseFlatten(array, isDeep, isStrict, result) {
+ function baseFlatten(array, depth, isStrict, result) {
result || (result = []);
var index = -1,
@@ -2508,11 +2552,11 @@
while (++index < length) {
var value = array[index];
- if (isArrayLikeObject(value) &&
+ if (depth > 0 && isArrayLikeObject(value) &&
(isStrict || isArray(value) || isArguments(value))) {
- if (isDeep) {
+ if (depth > 1) {
// Recursively flatten arrays (susceptible to call stack limits).
- baseFlatten(value, isDeep, isStrict, result);
+ baseFlatten(value, depth - 1, isStrict, result);
} else {
arrayPush(result, value);
}
@@ -2609,7 +2653,7 @@
* @returns {*} Returns the resolved value.
*/
function baseGet(object, path) {
- path = isKey(path, object) ? [path + ''] : baseToPath(path);
+ path = isKey(path, object) ? [path + ''] : baseCastPath(path);
var index = 0,
length = path.length;
@@ -2698,11 +2742,17 @@
var value = array[index],
computed = iteratee ? iteratee(value) : value;
- if (!(seen ? cacheHas(seen, computed) : includes(result, computed, comparator))) {
+ if (!(seen
+ ? cacheHas(seen, computed)
+ : includes(result, computed, comparator)
+ )) {
var othIndex = othLength;
while (--othIndex) {
var cache = caches[othIndex];
- if (!(cache ? cacheHas(cache, computed) : includes(arrays[othIndex], computed, comparator))) {
+ if (!(cache
+ ? cacheHas(cache, computed)
+ : includes(arrays[othIndex], computed, comparator))
+ ) {
continue outer;
}
}
@@ -2745,7 +2795,7 @@
*/
function baseInvoke(object, path, args) {
if (!isKey(path, object)) {
- path = baseToPath(path);
+ path = baseCastPath(path);
object = parent(object, path);
path = last(path);
}
@@ -2918,7 +2968,6 @@
* property of prototypes or treat sparse arrays as dense.
*
* @private
- * @type Function
* @param {Object} object The object to query.
* @returns {Array} Returns the array of property names.
*/
@@ -3026,7 +3075,10 @@
if (object === source) {
return;
}
- var props = (isArray(source) || isTypedArray(source)) ? undefined : keysIn(source);
+ var props = (isArray(source) || isTypedArray(source))
+ ? undefined
+ : keysIn(source);
+
arrayEach(props || source, function(srcValue, key) {
if (props) {
key = srcValue;
@@ -3037,7 +3089,10 @@
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
}
else {
- var newValue = customizer ? customizer(object[key], srcValue, (key + ''), object, source, stack) : undefined;
+ var newValue = customizer
+ ? customizer(object[key], srcValue, (key + ''), object, source, stack)
+ : undefined;
+
if (newValue === undefined) {
newValue = srcValue;
}
@@ -3069,21 +3124,24 @@
assignMergeValue(object, key, stacked);
return;
}
- var newValue = customizer ? customizer(objValue, srcValue, (key + ''), object, source, stack) : undefined,
- isCommon = newValue === undefined;
+ var newValue = customizer
+ ? customizer(objValue, srcValue, (key + ''), object, source, stack)
+ : undefined;
+
+ var isCommon = newValue === undefined;
if (isCommon) {
newValue = srcValue;
if (isArray(srcValue) || isTypedArray(srcValue)) {
if (isArray(objValue)) {
- newValue = srcIndex ? copyArray(objValue) : objValue;
+ newValue = objValue;
}
else if (isArrayLikeObject(objValue)) {
newValue = copyArray(objValue);
}
else {
isCommon = false;
- newValue = baseClone(srcValue);
+ newValue = baseClone(srcValue, true);
}
}
else if (isPlainObject(srcValue) || isArguments(srcValue)) {
@@ -3092,10 +3150,10 @@
}
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
isCommon = false;
- newValue = baseClone(srcValue);
+ newValue = baseClone(srcValue, true);
}
else {
- newValue = srcIndex ? baseClone(objValue) : objValue;
+ newValue = objValue;
}
}
else {
@@ -3269,7 +3327,7 @@
splice.call(array, index, 1);
}
else if (!isKey(index, array)) {
- var path = baseToPath(index),
+ var path = baseCastPath(index),
object = parent(array, path);
if (object != null) {
@@ -3331,7 +3389,7 @@
* @returns {Object} Returns `object`.
*/
function baseSet(object, path, value, customizer) {
- path = isKey(path, object) ? [path + ''] : baseToPath(path);
+ path = isKey(path, object) ? [path + ''] : baseCastPath(path);
var index = -1,
length = path.length,
@@ -3346,7 +3404,9 @@
var objValue = nested[key];
newValue = customizer ? customizer(objValue, key, nested) : undefined;
if (newValue === undefined) {
- newValue = objValue == null ? (isIndex(path[index + 1]) ? [] : {}) : objValue;
+ newValue = objValue == null
+ ? (isIndex(path[index + 1]) ? [] : {})
+ : objValue;
}
}
assignValue(nested, key, newValue);
@@ -3537,18 +3597,6 @@
return result;
}
- /**
- * The base implementation of `_.toPath` which only converts `value` to a
- * path if it's not one.
- *
- * @private
- * @param {*} value The value to process.
- * @returns {Array} Returns the property path array.
- */
- function baseToPath(value) {
- return isArray(value) ? value : stringToPath(value);
- }
-
/**
* The base implementation of `_.uniqBy` without support for iteratee shorthands.
*
@@ -3618,7 +3666,7 @@
* @returns {boolean} Returns `true` if the property is deleted, else `false`.
*/
function baseUnset(object, path) {
- path = isKey(path, object) ? [path + ''] : baseToPath(path);
+ path = isKey(path, object) ? [path + ''] : baseCastPath(path);
object = parent(object, path);
var key = last(path);
return (object != null && has(object, key)) ? delete object[key] : true;
@@ -3807,10 +3855,11 @@
* @returns {Object} Returns the cloned typed array.
*/
function cloneTypedArray(typedArray, isDeep) {
- var buffer = typedArray.buffer,
+ var arrayBuffer = typedArray.buffer,
+ buffer = isDeep ? cloneArrayBuffer(arrayBuffer) : arrayBuffer,
Ctor = typedArray.constructor;
- return new Ctor(isDeep ? cloneArrayBuffer(buffer) : buffer, typedArray.byteOffset, typedArray.length);
+ return new Ctor(buffer, typedArray.byteOffset, typedArray.length);
}
/**
@@ -3925,8 +3974,11 @@
length = props.length;
while (++index < length) {
- var key = props[index],
- newValue = customizer ? customizer(object[key], source[key], key, object, source) : source[key];
+ var key = props[index];
+
+ var newValue = customizer
+ ? customizer(object[key], source[key], key, object, source)
+ : source[key];
assignValue(object, key, newValue);
}
@@ -3976,7 +4028,10 @@
customizer = length > 1 ? sources[length - 1] : undefined,
guard = length > 2 ? sources[2] : undefined;
- customizer = typeof customizer == 'function' ? (length--, customizer) : undefined;
+ customizer = typeof customizer == 'function'
+ ? (length--, customizer)
+ : undefined;
+
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
customizer = length < 3 ? undefined : customizer;
length = 1;
@@ -4077,8 +4132,11 @@
return function(string) {
string = toString(string);
- var strSymbols = reHasComplexSymbol.test(string) ? stringToArray(string) : undefined,
- chr = strSymbols ? strSymbols[0] : string.charAt(0),
+ var strSymbols = reHasComplexSymbol.test(string)
+ ? stringToArray(string)
+ : undefined;
+
+ var chr = strSymbols ? strSymbols[0] : string.charAt(0),
trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1);
return chr[methodName]() + trailing;
@@ -4174,7 +4232,7 @@
*/
function createFlow(fromRight) {
return rest(function(funcs) {
- funcs = baseFlatten(funcs);
+ funcs = baseFlatten(funcs, 1);
var length = funcs.length,
index = length,
@@ -4199,7 +4257,10 @@
var funcName = getFuncName(func),
data = funcName == 'wrapper' ? getData(func) : undefined;
- if (data && isLaziable(data[0]) && data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) && !data[4].length && data[9] == 1) {
+ if (data && isLaziable(data[0]) &&
+ data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) &&
+ !data[4].length && data[9] == 1
+ ) {
wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
} else {
wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func);
@@ -4209,7 +4270,8 @@
var args = arguments,
value = args[0];
- if (wrapper && args.length == 1 && isArray(value) && value.length >= LARGE_ARRAY_SIZE) {
+ if (wrapper && args.length == 1 &&
+ isArray(value) && value.length >= LARGE_ARRAY_SIZE) {
return wrapper.plant(value).value();
}
var index = 0,
@@ -4269,7 +4331,10 @@
length -= argsHolders.length;
if (length < arity) {
- return createRecurryWrapper(func, bitmask, createHybridWrapper, placeholder, thisArg, args, argsHolders, argPos, ary, arity - length);
+ return createRecurryWrapper(
+ func, bitmask, createHybridWrapper, placeholder, thisArg, args,
+ argsHolders, argPos, ary, arity - length
+ );
}
}
var thisBinding = isBind ? thisArg : this,
@@ -4314,7 +4379,7 @@
*/
function createOver(arrayFunc) {
return rest(function(iteratees) {
- iteratees = arrayMap(baseFlatten(iteratees), getIteratee());
+ iteratees = arrayMap(baseFlatten(iteratees, 1), getIteratee());
return rest(function(args) {
var thisArg = this;
return arrayFunc(iteratees, function(iteratee) {
@@ -4441,9 +4506,12 @@
if (!(bitmask & CURRY_BOUND_FLAG)) {
bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
}
- var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, arity],
- result = wrapFunc.apply(undefined, newData);
+ var newData = [
+ func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight,
+ newHoldersRight, newArgPos, ary, arity
+ ];
+ var result = wrapFunc.apply(undefined, newData);
if (isLaziable(func)) {
setData(result, newData);
}
@@ -4532,8 +4600,12 @@
partials = holders = undefined;
}
- var data = isBindKey ? undefined : getData(func),
- newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity];
+ var data = isBindKey ? undefined : getData(func);
+
+ var newData = [
+ func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
+ argPos, ary, arity
+ ];
if (data) {
mergeData(newData, data);
@@ -4941,7 +5013,7 @@
}
var result = hasFunc(object, path);
if (!result && !isKey(path)) {
- path = baseToPath(path);
+ path = baseCastPath(path);
object = parent(object, path);
if (object != null) {
path = last(path);
@@ -5100,7 +5172,7 @@
function isKeyable(value) {
var type = typeof value;
return type == 'number' || type == 'boolean' ||
- (type == 'string' && value !== '__proto__') || value == null;
+ (type == 'string' && value != '__proto__') || value == null;
}
/**
@@ -5322,28 +5394,6 @@
return result;
}
- /**
- * Converts `value` to an array-like object if it's not one.
- *
- * @private
- * @param {*} value The value to process.
- * @returns {Array} Returns the array-like object.
- */
- function toArrayLikeObject(value) {
- return isArrayLikeObject(value) ? value : [];
- }
-
- /**
- * Converts `value` to a function if it's not one.
- *
- * @private
- * @param {*} value The value to process.
- * @returns {Function} Returns the function.
- */
- function toFunction(value) {
- return typeof value == 'function' ? value : identity;
- }
-
/**
* Creates a clone of `wrapper`.
*
@@ -5454,7 +5504,7 @@
if (!isArray(array)) {
array = array == null ? [] : [Object(array)];
}
- values = baseFlatten(values);
+ values = baseFlatten(values, 1);
return arrayConcat(array, values);
});
@@ -5476,7 +5526,7 @@
*/
var difference = rest(function(array, values) {
return isArrayLikeObject(array)
- ? baseDifference(array, baseFlatten(values, false, true))
+ ? baseDifference(array, baseFlatten(values, 1, true))
: [];
});
@@ -5507,7 +5557,7 @@
iteratee = undefined;
}
return isArrayLikeObject(array)
- ? baseDifference(array, baseFlatten(values, false, true), getIteratee(iteratee))
+ ? baseDifference(array, baseFlatten(values, 1, true), getIteratee(iteratee))
: [];
});
@@ -5536,7 +5586,7 @@
comparator = undefined;
}
return isArrayLikeObject(array)
- ? baseDifference(array, baseFlatten(values, false, true), undefined, comparator)
+ ? baseDifference(array, baseFlatten(values, 1, true), undefined, comparator)
: [];
});
@@ -5806,7 +5856,7 @@
}
/**
- * Flattens `array` a single level.
+ * Flattens `array` a single level deep.
*
* @static
* @memberOf _
@@ -5815,30 +5865,58 @@
* @returns {Array} Returns the new flattened array.
* @example
*
- * _.flatten([1, [2, 3, [4]]]);
- * // => [1, 2, 3, [4]]
+ * _.flatten([1, [2, [3, [4]], 5]]);
+ * // => [1, 2, [3, [4]], 5]
*/
function flatten(array) {
var length = array ? array.length : 0;
- return length ? baseFlatten(array) : [];
+ return length ? baseFlatten(array, 1) : [];
}
/**
- * This method is like `_.flatten` except that it recursively flattens `array`.
+ * Recursively flattens `array`.
*
* @static
* @memberOf _
* @category Array
- * @param {Array} array The array to recursively flatten.
+ * @param {Array} array The array to flatten.
* @returns {Array} Returns the new flattened array.
* @example
*
- * _.flattenDeep([1, [2, 3, [4]]]);
- * // => [1, 2, 3, 4]
+ * _.flattenDeep([1, [2, [3, [4]], 5]]);
+ * // => [1, 2, 3, 4, 5]
*/
function flattenDeep(array) {
var length = array ? array.length : 0;
- return length ? baseFlatten(array, true) : [];
+ return length ? baseFlatten(array, INFINITY) : [];
+ }
+
+ /**
+ * Recursively flatten `array` up to `depth` times.
+ *
+ * @static
+ * @memberOf _
+ * @category Array
+ * @param {Array} array The array to flatten.
+ * @param {number} [depth=1] The maximum recursion depth.
+ * @returns {Array} Returns the new flattened array.
+ * @example
+ *
+ * var array = [1, [2, [3, [4]], 5]];
+ *
+ * _.flattenDepth(array, 1);
+ * // => [1, 2, [3, [4]], 5]
+ *
+ * _.flattenDepth(array, 2);
+ * // => [1, 2, 3, [4], 5]
+ */
+ function flattenDepth(array, depth) {
+ var length = array ? array.length : 0;
+ if (!length) {
+ return [];
+ }
+ depth = depth === undefined ? 1 : toInteger(depth);
+ return baseFlatten(array, depth);
}
/**
@@ -5955,7 +6033,7 @@
* // => [2]
*/
var intersection = rest(function(arrays) {
- var mapped = arrayMap(arrays, toArrayLikeObject);
+ var mapped = arrayMap(arrays, baseCastArrayLikeObject);
return (mapped.length && mapped[0] === arrays[0])
? baseIntersection(mapped)
: [];
@@ -5983,7 +6061,7 @@
*/
var intersectionBy = rest(function(arrays) {
var iteratee = last(arrays),
- mapped = arrayMap(arrays, toArrayLikeObject);
+ mapped = arrayMap(arrays, baseCastArrayLikeObject);
if (iteratee === last(mapped)) {
iteratee = undefined;
@@ -6016,7 +6094,7 @@
*/
var intersectionWith = rest(function(arrays) {
var comparator = last(arrays),
- mapped = arrayMap(arrays, toArrayLikeObject);
+ mapped = arrayMap(arrays, baseCastArrayLikeObject);
if (comparator === last(mapped)) {
comparator = undefined;
@@ -6206,7 +6284,7 @@
* // => [10, 20]
*/
var pullAt = rest(function(array, indexes) {
- indexes = arrayMap(baseFlatten(indexes), String);
+ indexes = arrayMap(baseFlatten(indexes, 1), String);
var result = baseAt(array, indexes);
basePullAt(array, indexes.sort(compareAscending));
@@ -6678,7 +6756,7 @@
* // => [2, 1, 4]
*/
var union = rest(function(arrays) {
- return baseUniq(baseFlatten(arrays, false, true));
+ return baseUniq(baseFlatten(arrays, 1, true));
});
/**
@@ -6706,7 +6784,7 @@
if (isArrayLikeObject(iteratee)) {
iteratee = undefined;
}
- return baseUniq(baseFlatten(arrays, false, true), getIteratee(iteratee));
+ return baseUniq(baseFlatten(arrays, 1, true), getIteratee(iteratee));
});
/**
@@ -6733,7 +6811,7 @@
if (isArrayLikeObject(comparator)) {
comparator = undefined;
}
- return baseUniq(baseFlatten(arrays, false, true), undefined, comparator);
+ return baseUniq(baseFlatten(arrays, 1, true), undefined, comparator);
});
/**
@@ -7157,17 +7235,22 @@
* // => ['a', 'c']
*/
var wrapperAt = rest(function(paths) {
- paths = baseFlatten(paths);
+ paths = baseFlatten(paths, 1);
var length = paths.length,
start = length ? paths[0] : 0,
value = this.__wrapped__,
interceptor = function(object) { return baseAt(object, paths); };
- if (length > 1 || this.__actions__.length || !(value instanceof LazyWrapper) || !isIndex(start)) {
+ if (length > 1 || this.__actions__.length ||
+ !(value instanceof LazyWrapper) || !isIndex(start)) {
return this.thru(interceptor);
}
value = value.slice(start, +start + (length ? 1 : 0));
- value.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
+ value.__actions__.push({
+ 'func': thru,
+ 'args': [interceptor],
+ 'thisArg': undefined
+ });
return new LodashWrapper(value, this.__chain__).thru(function(array) {
if (length && !array.length) {
array.push(undefined);
@@ -7378,7 +7461,11 @@
wrapped = new LazyWrapper(this);
}
wrapped = wrapped.reverse();
- wrapped.__actions__.push({ 'func': thru, 'args': [reverse], 'thisArg': undefined });
+ wrapped.__actions__.push({
+ 'func': thru,
+ 'args': [reverse],
+ 'thisArg': undefined
+ });
return new LodashWrapper(wrapped, this.__chain__);
}
return this.thru(reverse);
@@ -7597,7 +7684,7 @@
* // => [1, 1, 2, 2]
*/
function flatMap(collection, iteratee) {
- return baseFlatten(map(collection, iteratee));
+ return baseFlatten(map(collection, iteratee), 1);
}
/**
@@ -7631,7 +7718,7 @@
function forEach(collection, iteratee) {
return (typeof iteratee == 'function' && isArray(collection))
? arrayEach(collection, iteratee)
- : baseEach(collection, toFunction(iteratee));
+ : baseEach(collection, baseCastFunction(iteratee));
}
/**
@@ -7655,7 +7742,7 @@
function forEachRight(collection, iteratee) {
return (typeof iteratee == 'function' && isArray(collection))
? arrayEachRight(collection, iteratee)
- : baseEachRight(collection, toFunction(iteratee));
+ : baseEachRight(collection, baseCastFunction(iteratee));
}
/**
@@ -8219,7 +8306,7 @@
} else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
iteratees.length = 1;
}
- return baseOrderBy(collection, baseFlatten(iteratees), []);
+ return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
});
/*------------------------------------------------------------------------*/
@@ -8230,7 +8317,7 @@
*
* @static
* @memberOf _
- * @type Function
+ * @type {Function}
* @category Date
* @returns {number} Returns the timestamp.
* @example
@@ -8656,8 +8743,10 @@
if (!lastCalled && !maxTimeoutId && !leading) {
lastCalled = stamp;
}
- var remaining = maxWait - (stamp - lastCalled),
- isCalled = remaining <= 0 || remaining > maxWait;
+ var remaining = maxWait - (stamp - lastCalled);
+
+ var isCalled = (remaining <= 0 || remaining > maxWait) &&
+ (leading || maxTimeoutId);
if (isCalled) {
if (maxTimeoutId) {
@@ -8897,7 +8986,7 @@
* // => [100, 10]
*/
var overArgs = rest(function(func, transforms) {
- transforms = arrayMap(baseFlatten(transforms), getIteratee());
+ transforms = arrayMap(baseFlatten(transforms, 1), getIteratee());
var funcsLength = transforms.length;
return rest(function(args) {
@@ -9011,7 +9100,7 @@
* // => ['a', 'b', 'c']
*/
var rearg = rest(function(func, indexes) {
- return createWrapper(func, REARG_FLAG, undefined, undefined, undefined, baseFlatten(indexes));
+ return createWrapper(func, REARG_FLAG, undefined, undefined, undefined, baseFlatten(indexes, 1));
});
/**
@@ -9163,7 +9252,11 @@
leading = 'leading' in options ? !!options.leading : leading;
trailing = 'trailing' in options ? !!options.trailing : trailing;
}
- return debounce(func, wait, { 'leading': leading, 'maxWait': wait, 'trailing': trailing });
+ return debounce(func, wait, {
+ 'leading': leading,
+ 'maxWait': wait,
+ 'trailing': trailing
+ });
}
/**
@@ -9194,7 +9287,7 @@
* @memberOf _
* @category Function
* @param {*} value The value to wrap.
- * @param {Function} wrapper The wrapper function.
+ * @param {Function} [wrapper=identity] The wrapper function.
* @returns {Function} Returns the new function.
* @example
*
@@ -9212,6 +9305,46 @@
/*------------------------------------------------------------------------*/
+ /**
+ * Casts `value` as an array if it's not one.
+ *
+ * @static
+ * @memberOf _
+ * @category Lang
+ * @param {*} value The value to inspect.
+ * @returns {Array} Returns the cast array.
+ * @example
+ *
+ * _.castArray(1);
+ * // => [1]
+ *
+ * _.castArray({ 'a': 1 });
+ * // => [{ 'a': 1 }]
+ *
+ * _.castArray('abc');
+ * // => ['abc']
+ *
+ * _.castArray(null);
+ * // => [null]
+ *
+ * _.castArray(undefined);
+ * // => [undefined]
+ *
+ * _.castArray();
+ * // => []
+ *
+ * var array = [1, 2, 3];
+ * console.log(_.castArray(array) === array);
+ * // => true
+ */
+ function castArray() {
+ if (!arguments.length) {
+ return [];
+ }
+ var value = arguments[0];
+ return isArray(value) ? value : [value];
+ }
+
/**
* Creates a shallow clone of `value`.
*
@@ -9432,7 +9565,7 @@
*
* @static
* @memberOf _
- * @type Function
+ * @type {Function}
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
@@ -9457,7 +9590,6 @@
*
* @static
* @memberOf _
- * @type Function
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
@@ -9480,7 +9612,6 @@
*
* @static
* @memberOf _
- * @type Function
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
@@ -9509,7 +9640,6 @@
*
* @static
* @memberOf _
- * @type Function
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an array-like object, else `false`.
@@ -9641,7 +9771,8 @@
*/
function isEmpty(value) {
if (isArrayLike(value) &&
- (isArray(value) || isString(value) || isFunction(value.splice) || isArguments(value))) {
+ (isArray(value) || isString(value) ||
+ isFunction(value.splice) || isArguments(value))) {
return !value.length;
}
for (var key in value) {
@@ -9684,10 +9815,10 @@
}
/**
- * This method is like `_.isEqual` except that it accepts `customizer` which is
- * invoked to compare values. If `customizer` returns `undefined` comparisons are
- * handled by the method instead. The `customizer` is invoked with up to six arguments:
- * (objValue, othValue [, index|key, object, other, stack]).
+ * This method is like `_.isEqual` except that it accepts `customizer` which
+ * is invoked to compare values. If `customizer` returns `undefined` comparisons
+ * are handled by the method instead. The `customizer` is invoked with up to
+ * six arguments: (objValue, othValue [, index|key, object, other, stack]).
*
* @static
* @memberOf _
@@ -9738,8 +9869,12 @@
* // => false
*/
function isError(value) {
- return isObjectLike(value) &&
- typeof value.message == 'string' && objectToString.call(value) == errorTag;
+ if (!isObjectLike(value)) {
+ return false;
+ }
+ var Ctor = value.constructor;
+ return (objectToString.call(value) == errorTag) ||
+ (typeof Ctor == 'function' && objectToString.call(Ctor.prototype) == errorTag);
}
/**
@@ -9847,7 +9982,8 @@
* // => false
*/
function isLength(value) {
- return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
+ return typeof value == 'number' &&
+ value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
}
/**
@@ -9926,8 +10062,9 @@
}
/**
- * Performs a deep comparison between `object` and `source` to determine if
- * `object` contains equivalent property values.
+ * Performs a partial deep comparison between `object` and `source` to
+ * determine if `object` contains equivalent property values. This method is
+ * equivalent to a `_.matches` function when `source` is partially applied.
*
* **Note:** This method supports comparing the same values as `_.isEqual`.
*
@@ -10146,7 +10283,8 @@
* // => true
*/
function isPlainObject(value) {
- if (!isObjectLike(value) || objectToString.call(value) != objectTag || isHostObject(value)) {
+ if (!isObjectLike(value) ||
+ objectToString.call(value) != objectTag || isHostObject(value)) {
return false;
}
var proto = objectProto;
@@ -10289,7 +10427,8 @@
* // => false
*/
function isTypedArray(value) {
- return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
+ return isObjectLike(value) &&
+ isLength(value.length) && !!typedArrayTags[objectToString.call(value)];
}
/**
@@ -10781,7 +10920,7 @@
* // => ['a', 'c']
*/
var at = rest(function(object, paths) {
- return baseAt(object, baseFlatten(paths));
+ return baseAt(object, baseFlatten(paths, 1));
});
/**
@@ -10969,7 +11108,9 @@
* // => logs 'a', 'b', then 'c' (iteration order is not guaranteed)
*/
function forIn(object, iteratee) {
- return object == null ? object : baseFor(object, toFunction(iteratee), keysIn);
+ return object == null
+ ? object
+ : baseFor(object, baseCastFunction(iteratee), keysIn);
}
/**
@@ -10997,7 +11138,9 @@
* // => logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'
*/
function forInRight(object, iteratee) {
- return object == null ? object : baseForRight(object, toFunction(iteratee), keysIn);
+ return object == null
+ ? object
+ : baseForRight(object, baseCastFunction(iteratee), keysIn);
}
/**
@@ -11027,7 +11170,7 @@
* // => logs 'a' then 'b' (iteration order is not guaranteed)
*/
function forOwn(object, iteratee) {
- return object && baseForOwn(object, toFunction(iteratee));
+ return object && baseForOwn(object, baseCastFunction(iteratee));
}
/**
@@ -11055,7 +11198,7 @@
* // => logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'
*/
function forOwnRight(object, iteratee) {
- return object && baseForOwnRight(object, toFunction(iteratee));
+ return object && baseForOwnRight(object, baseCastFunction(iteratee));
}
/**
@@ -11422,12 +11565,12 @@
}
/**
- * Recursively merges own and inherited enumerable properties of source
- * objects into the destination object, skipping source properties that resolve
- * to `undefined`. Array and plain object properties are merged recursively.
- * Other objects and value types are overridden by assignment. Source objects
- * are applied from left to right. Subsequent sources overwrite property
- * assignments of previous sources.
+ * Recursively merges own and inherited enumerable properties of source objects
+ * into the destination object. Source properties that resolve to `undefined`
+ * are skipped if a destination value exists. Array and plain object properties
+ * are merged recursively. Other objects and value types are overridden by
+ * assignment. Source objects are applied from left to right. Subsequent
+ * sources overwrite property assignments of previous sources.
*
* **Note:** This method mutates `object`.
*
@@ -11504,7 +11647,7 @@
* @category Object
* @param {Object} object The source object.
* @param {...(string|string[])} [props] The property names to omit, specified
- * individually or in arrays..
+ * individually or in arrays.
* @returns {Object} Returns the new object.
* @example
*
@@ -11517,7 +11660,7 @@
if (object == null) {
return {};
}
- props = arrayMap(baseFlatten(props), String);
+ props = arrayMap(baseFlatten(props, 1), String);
return basePick(object, baseDifference(keysIn(object), props));
});
@@ -11564,7 +11707,7 @@
* // => { 'a': 1, 'c': 3 }
*/
var pick = rest(function(object, props) {
- return object == null ? {} : basePick(object, baseFlatten(props));
+ return object == null ? {} : basePick(object, baseFlatten(props, 1));
});
/**
@@ -11618,7 +11761,7 @@
*/
function result(object, path, defaultValue) {
if (!isKey(path, object)) {
- path = baseToPath(path);
+ path = baseCastPath(path);
var result = get(object, path);
object = parent(object, path);
} else {
@@ -11688,7 +11831,8 @@
}
/**
- * Creates an array of own enumerable key-value pairs for `object`.
+ * Creates an array of own enumerable key-value pairs for `object` which
+ * can be consumed by `_.fromPairs`.
*
* @static
* @memberOf _
@@ -11712,7 +11856,8 @@
}
/**
- * Creates an array of own and inherited enumerable key-value pairs for `object`.
+ * Creates an array of own and inherited enumerable key-value pairs for
+ * `object` which can be consumed by `_.fromPairs`.
*
* @static
* @memberOf _
@@ -11867,7 +12012,7 @@
* // => [1, 2, 3] (iteration order is not guaranteed)
*/
function valuesIn(object) {
- return object == null ? baseValues(object, keysIn(object)) : [];
+ return object == null ? [] : baseValues(object, keysIn(object));
}
/*------------------------------------------------------------------------*/
@@ -12365,7 +12510,7 @@
* @memberOf _
* @category String
* @param {string} string The string to convert.
- * @param {number} [radix] The radix to interpret `value` by.
+ * @param {number} [radix=10] The radix to interpret `value` by.
* @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`.
* @returns {number} Returns the converted integer.
* @example
@@ -12737,7 +12882,8 @@
'return __p\n}';
var result = attempt(function() {
- return Function(importsKeys, sourceURL + 'return ' + source).apply(undefined, importsValues);
+ return Function(importsKeys, sourceURL + 'return ' + source)
+ .apply(undefined, importsValues);
});
// Provide the compiled function's source by its `toString` method or
@@ -12831,7 +12977,9 @@
var strSymbols = stringToArray(string),
chrSymbols = stringToArray(chars);
- return strSymbols.slice(charsStartIndex(strSymbols, chrSymbols), charsEndIndex(strSymbols, chrSymbols) + 1).join('');
+ return strSymbols
+ .slice(charsStartIndex(strSymbols, chrSymbols), charsEndIndex(strSymbols, chrSymbols) + 1)
+ .join('');
}
/**
@@ -12865,7 +13013,9 @@
return string;
}
var strSymbols = stringToArray(string);
- return strSymbols.slice(0, charsEndIndex(strSymbols, stringToArray(chars)) + 1).join('');
+ return strSymbols
+ .slice(0, charsEndIndex(strSymbols, stringToArray(chars)) + 1)
+ .join('');
}
/**
@@ -12899,7 +13049,9 @@
return string;
}
var strSymbols = stringToArray(string);
- return strSymbols.slice(charsStartIndex(strSymbols, stringToArray(chars))).join('');
+ return strSymbols
+ .slice(charsStartIndex(strSymbols, stringToArray(chars)))
+ .join('');
}
/**
@@ -12911,7 +13063,7 @@
* @memberOf _
* @category String
* @param {string} [string=''] The string to truncate.
- * @param {Object} [options] The options object.
+ * @param {Object} [options=({})] The options object.
* @param {number} [options.length=30] The maximum string length.
* @param {string} [options.omission='...'] The string to indicate text is omitted.
* @param {RegExp|string} [options.separator] The separator pattern to truncate to.
@@ -13096,7 +13248,7 @@
try {
return apply(func, undefined, args);
} catch (e) {
- return isObject(e) ? e : new Error(e);
+ return isError(e) ? e : new Error(e);
}
});
@@ -13127,7 +13279,7 @@
* // => logs 'clicked docs' when clicked
*/
var bindAll = rest(function(object, methodNames) {
- arrayEach(baseFlatten(methodNames), function(key) {
+ arrayEach(baseFlatten(methodNames, 1), function(key) {
object[key] = bind(object[key], object);
});
return object;
@@ -13295,7 +13447,8 @@
* Creates a function that invokes `func` with the arguments of the created
* function. If `func` is a property name the created callback returns the
* property value for a given element. If `func` is an object the created
- * callback returns `true` for elements that contain the equivalent object properties, otherwise it returns `false`.
+ * callback returns `true` for elements that contain the equivalent object
+ * properties, otherwise it returns `false`.
*
* @static
* @memberOf _
@@ -13325,9 +13478,10 @@
}
/**
- * Creates a function that performs a deep partial comparison between a given
+ * Creates a function that performs a partial deep comparison between a given
* object and `source`, returning `true` if the given object has equivalent
- * property values, else `false`.
+ * property values, else `false`. The created function is equivalent to
+ * `_.isMatch` with a `source` partially applied.
*
* **Note:** This method supports comparing the same values as `_.isEqual`.
*
@@ -13351,7 +13505,7 @@
}
/**
- * Creates a function that performs a deep partial comparison between the
+ * Creates a function that performs a partial deep comparison between the
* value at `path` of a given object to `srcValue`, returning `true` if the
* object value is equivalent, else `false`.
*
@@ -13785,7 +13939,7 @@
var index = MAX_ARRAY_LENGTH,
length = nativeMin(n, MAX_ARRAY_LENGTH);
- iteratee = toFunction(iteratee);
+ iteratee = baseCastFunction(iteratee);
n -= MAX_ARRAY_LENGTH;
var result = baseTimes(length, iteratee);
@@ -13830,7 +13984,7 @@
* @static
* @memberOf _
* @category Util
- * @param {string} [prefix] The value to prefix the ID with.
+ * @param {string} [prefix=''] The value to prefix the ID with.
* @returns {string} Returns the unique ID.
* @example
*
@@ -14181,6 +14335,7 @@
lodash.bind = bind;
lodash.bindAll = bindAll;
lodash.bindKey = bindKey;
+ lodash.castArray = castArray;
lodash.chain = chain;
lodash.chunk = chunk;
lodash.compact = compact;
@@ -14209,6 +14364,7 @@
lodash.flatMap = flatMap;
lodash.flatten = flatten;
lodash.flattenDeep = flattenDeep;
+ lodash.flattenDepth = flattenDepth;
lodash.flip = flip;
lodash.flow = flow;
lodash.flowRight = flowRight;
@@ -14483,7 +14639,7 @@
*
* @static
* @memberOf _
- * @type string
+ * @type {string}
*/
lodash.VERSION = VERSION;
@@ -14505,7 +14661,10 @@
if (filtered) {
result.__takeCount__ = nativeMin(n, result.__takeCount__);
} else {
- result.__views__.push({ 'size': nativeMin(n, MAX_ARRAY_LENGTH), 'type': methodName + (result.__dir__ < 0 ? 'Right' : '') });
+ result.__views__.push({
+ 'size': nativeMin(n, MAX_ARRAY_LENGTH),
+ 'type': methodName + (result.__dir__ < 0 ? 'Right' : '')
+ });
}
return result;
};
@@ -14522,7 +14681,10 @@
LazyWrapper.prototype[methodName] = function(iteratee) {
var result = this.clone();
- result.__iteratees__.push({ 'iteratee': getIteratee(iteratee, 3), 'type': type });
+ result.__iteratees__.push({
+ 'iteratee': getIteratee(iteratee, 3),
+ 'type': type
+ });
result.__filtered__ = result.__filtered__ || isFilter;
return result;
};
@@ -14674,7 +14836,10 @@
}
});
- realNames[createHybridWrapper(undefined, BIND_KEY_FLAG).name] = [{ 'name': 'wrapper', 'func': undefined }];
+ realNames[createHybridWrapper(undefined, BIND_KEY_FLAG).name] = [{
+ 'name': 'wrapper',
+ 'func': undefined
+ }];
// Add functions to the lazy wrapper.
LazyWrapper.prototype.clone = lazyClone;
diff --git a/matches.js b/matches.js
index 99398eac0..413e39607 100644
--- a/matches.js
+++ b/matches.js
@@ -1,9 +1,10 @@
define(['./_baseClone', './_baseMatches'], function(baseClone, baseMatches) {
/**
- * Creates a function that performs a deep partial comparison between a given
+ * Creates a function that performs a partial deep comparison between a given
* object and `source`, returning `true` if the given object has equivalent
- * property values, else `false`.
+ * property values, else `false`. The created function is equivalent to
+ * `_.isMatch` with a `source` partially applied.
*
* **Note:** This method supports comparing the same values as `_.isEqual`.
*
diff --git a/matchesProperty.js b/matchesProperty.js
index f47f71e1b..7f4c6ada0 100644
--- a/matchesProperty.js
+++ b/matchesProperty.js
@@ -1,7 +1,7 @@
define(['./_baseClone', './_baseMatchesProperty'], function(baseClone, baseMatchesProperty) {
/**
- * Creates a function that performs a deep partial comparison between the
+ * Creates a function that performs a partial deep comparison between the
* value at `path` of a given object to `srcValue`, returning `true` if the
* object value is equivalent, else `false`.
*
diff --git a/merge.js b/merge.js
index 9e33901d8..f7d1c65c0 100644
--- a/merge.js
+++ b/merge.js
@@ -1,12 +1,12 @@
define(['./_baseMerge', './_createAssigner'], function(baseMerge, createAssigner) {
/**
- * Recursively merges own and inherited enumerable properties of source
- * objects into the destination object, skipping source properties that resolve
- * to `undefined`. Array and plain object properties are merged recursively.
- * Other objects and value types are overridden by assignment. Source objects
- * are applied from left to right. Subsequent sources overwrite property
- * assignments of previous sources.
+ * Recursively merges own and inherited enumerable properties of source objects
+ * into the destination object. Source properties that resolve to `undefined`
+ * are skipped if a destination value exists. Array and plain object properties
+ * are merged recursively. Other objects and value types are overridden by
+ * assignment. Source objects are applied from left to right. Subsequent
+ * sources overwrite property assignments of previous sources.
*
* **Note:** This method mutates `object`.
*
diff --git a/now.js b/now.js
index 8963f2a96..f84dcff36 100644
--- a/now.js
+++ b/now.js
@@ -6,7 +6,7 @@ define([], function() {
*
* @static
* @memberOf _
- * @type Function
+ * @type {Function}
* @category Date
* @returns {number} Returns the timestamp.
* @example
diff --git a/omit.js b/omit.js
index e4e9978c9..2d4303713 100644
--- a/omit.js
+++ b/omit.js
@@ -9,7 +9,7 @@ define(['./_arrayMap', './_baseDifference', './_baseFlatten', './_basePick', './
* @category Object
* @param {Object} object The source object.
* @param {...(string|string[])} [props] The property names to omit, specified
- * individually or in arrays..
+ * individually or in arrays.
* @returns {Object} Returns the new object.
* @example
*
@@ -22,7 +22,7 @@ define(['./_arrayMap', './_baseDifference', './_baseFlatten', './_basePick', './
if (object == null) {
return {};
}
- props = arrayMap(baseFlatten(props), String);
+ props = arrayMap(baseFlatten(props, 1), String);
return basePick(object, baseDifference(keysIn(object), props));
});
diff --git a/overArgs.js b/overArgs.js
index 025145560..ef78e6a31 100644
--- a/overArgs.js
+++ b/overArgs.js
@@ -35,7 +35,7 @@ define(['./_apply', './_arrayMap', './_baseFlatten', './_baseIteratee', './rest'
* // => [100, 10]
*/
var overArgs = rest(function(func, transforms) {
- transforms = arrayMap(baseFlatten(transforms), baseIteratee);
+ transforms = arrayMap(baseFlatten(transforms, 1), baseIteratee);
var funcsLength = transforms.length;
return rest(function(args) {
diff --git a/package.json b/package.json
index 6fef2de90..4475b7c37 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "lodash-amd",
- "version": "4.3.0",
+ "version": "4.4.0",
"description": "Lodash exported as AMD modules.",
"homepage": "https://lodash.com/custom-builds",
"license": "MIT",
diff --git a/parseInt.js b/parseInt.js
index 615a7afb8..93f994f81 100644
--- a/parseInt.js
+++ b/parseInt.js
@@ -21,7 +21,7 @@ define(['./_root', './toString'], function(root, toString) {
* @memberOf _
* @category String
* @param {string} string The string to convert.
- * @param {number} [radix] The radix to interpret `value` by.
+ * @param {number} [radix=10] The radix to interpret `value` by.
* @param- {Object} [guard] Enables use as an iteratee for functions like `_.map`.
* @returns {number} Returns the converted integer.
* @example
diff --git a/pick.js b/pick.js
index b22384daf..182ff3665 100644
--- a/pick.js
+++ b/pick.js
@@ -18,7 +18,7 @@ define(['./_baseFlatten', './_basePick', './rest'], function(baseFlatten, basePi
* // => { 'a': 1, 'c': 3 }
*/
var pick = rest(function(object, props) {
- return object == null ? {} : basePick(object, baseFlatten(props));
+ return object == null ? {} : basePick(object, baseFlatten(props, 1));
});
return pick;
diff --git a/pullAt.js b/pullAt.js
index a04bfe5fa..8b789b1c9 100644
--- a/pullAt.js
+++ b/pullAt.js
@@ -25,7 +25,7 @@ define(['./_arrayMap', './_baseAt', './_baseFlatten', './_basePullAt', './_compa
* // => [10, 20]
*/
var pullAt = rest(function(array, indexes) {
- indexes = arrayMap(baseFlatten(indexes), String);
+ indexes = arrayMap(baseFlatten(indexes, 1), String);
var result = baseAt(array, indexes);
basePullAt(array, indexes.sort(compareAscending));
diff --git a/rearg.js b/rearg.js
index 15b7a16d3..a30e435a9 100644
--- a/rearg.js
+++ b/rearg.js
@@ -29,7 +29,7 @@ define(['./_baseFlatten', './_createWrapper', './rest'], function(baseFlatten, c
* // => ['a', 'b', 'c']
*/
var rearg = rest(function(func, indexes) {
- return createWrapper(func, REARG_FLAG, undefined, undefined, undefined, baseFlatten(indexes));
+ return createWrapper(func, REARG_FLAG, undefined, undefined, undefined, baseFlatten(indexes, 1));
});
return rearg;
diff --git a/result.js b/result.js
index 33fb2eec1..1d795e1cf 100644
--- a/result.js
+++ b/result.js
@@ -1,4 +1,4 @@
-define(['./_baseToPath', './get', './isFunction', './_isKey', './_parent'], function(baseToPath, get, isFunction, isKey, parent) {
+define(['./_baseCastPath', './get', './isFunction', './_isKey', './_parent'], function(baseCastPath, get, isFunction, isKey, parent) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -33,7 +33,7 @@ define(['./_baseToPath', './get', './isFunction', './_isKey', './_parent'], func
*/
function result(object, path, defaultValue) {
if (!isKey(path, object)) {
- path = baseToPath(path);
+ path = baseCastPath(path);
var result = get(object, path);
object = parent(object, path);
} else {
diff --git a/sortBy.js b/sortBy.js
index bd85cc563..6a98f05b0 100644
--- a/sortBy.js
+++ b/sortBy.js
@@ -43,7 +43,7 @@ define(['./_baseFlatten', './_baseOrderBy', './_isIterateeCall', './rest'], func
} else if (length > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
iteratees.length = 1;
}
- return baseOrderBy(collection, baseFlatten(iteratees), []);
+ return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
});
return sortBy;
diff --git a/template.js b/template.js
index 3d6943b28..f1b4909ff 100644
--- a/template.js
+++ b/template.js
@@ -203,7 +203,8 @@ define(['./_assignInDefaults', './assignInWith', './attempt', './_baseValues', '
'return __p\n}';
var result = attempt(function() {
- return Function(importsKeys, sourceURL + 'return ' + source).apply(undefined, importsValues);
+ return Function(importsKeys, sourceURL + 'return ' + source)
+ .apply(undefined, importsValues);
});
// Provide the compiled function's source by its `toString` method or
diff --git a/templateSettings.js b/templateSettings.js
index 1cf7abe9c..64d182261 100644
--- a/templateSettings.js
+++ b/templateSettings.js
@@ -7,7 +7,7 @@ define(['./escape', './_reEscape', './_reEvaluate', './_reInterpolate'], functio
*
* @static
* @memberOf _
- * @type Object
+ * @type {Object}
*/
var templateSettings = {
@@ -15,7 +15,7 @@ define(['./escape', './_reEscape', './_reEvaluate', './_reInterpolate'], functio
* Used to detect `data` property values to be HTML-escaped.
*
* @memberOf _.templateSettings
- * @type RegExp
+ * @type {RegExp}
*/
'escape': reEscape,
@@ -23,7 +23,7 @@ define(['./escape', './_reEscape', './_reEvaluate', './_reInterpolate'], functio
* Used to detect code to be evaluated.
*
* @memberOf _.templateSettings
- * @type RegExp
+ * @type {RegExp}
*/
'evaluate': reEvaluate,
@@ -31,7 +31,7 @@ define(['./escape', './_reEscape', './_reEvaluate', './_reInterpolate'], functio
* Used to detect `data` property values to inject.
*
* @memberOf _.templateSettings
- * @type RegExp
+ * @type {RegExp}
*/
'interpolate': reInterpolate,
@@ -39,7 +39,7 @@ define(['./escape', './_reEscape', './_reEvaluate', './_reInterpolate'], functio
* Used to reference the data object in the template text.
*
* @memberOf _.templateSettings
- * @type string
+ * @type {string}
*/
'variable': '',
@@ -47,7 +47,7 @@ define(['./escape', './_reEscape', './_reEvaluate', './_reInterpolate'], functio
* Used to import variables into the compiled template.
*
* @memberOf _.templateSettings
- * @type Object
+ * @type {Object}
*/
'imports': {
@@ -55,7 +55,7 @@ define(['./escape', './_reEscape', './_reEvaluate', './_reInterpolate'], functio
* A reference to the `lodash` function.
*
* @memberOf _.templateSettings.imports
- * @type Function
+ * @type {Function}
*/
'_': { 'escape': escape }
}
diff --git a/throttle.js b/throttle.js
index bc32e5bce..e84e94a42 100644
--- a/throttle.js
+++ b/throttle.js
@@ -54,7 +54,11 @@ define(['./debounce', './isObject'], function(debounce, isObject) {
leading = 'leading' in options ? !!options.leading : leading;
trailing = 'trailing' in options ? !!options.trailing : trailing;
}
- return debounce(func, wait, { 'leading': leading, 'maxWait': wait, 'trailing': trailing });
+ return debounce(func, wait, {
+ 'leading': leading,
+ 'maxWait': wait,
+ 'trailing': trailing
+ });
}
return throttle;
diff --git a/times.js b/times.js
index b7959e9bd..de69c70af 100644
--- a/times.js
+++ b/times.js
@@ -1,4 +1,4 @@
-define(['./_baseTimes', './_toFunction', './toInteger'], function(baseTimes, toFunction, toInteger) {
+define(['./_baseCastFunction', './_baseTimes', './toInteger'], function(baseCastFunction, baseTimes, toInteger) {
/** Used as references for various `Number` constants. */
var MAX_SAFE_INTEGER = 9007199254740991;
@@ -35,7 +35,7 @@ define(['./_baseTimes', './_toFunction', './toInteger'], function(baseTimes, toF
var index = MAX_ARRAY_LENGTH,
length = nativeMin(n, MAX_ARRAY_LENGTH);
- iteratee = toFunction(iteratee);
+ iteratee = baseCastFunction(iteratee);
n -= MAX_ARRAY_LENGTH;
var result = baseTimes(length, iteratee);
diff --git a/toPairs.js b/toPairs.js
index 254faabd3..36abfb69d 100644
--- a/toPairs.js
+++ b/toPairs.js
@@ -1,7 +1,8 @@
define(['./_baseToPairs', './keys'], function(baseToPairs, keys) {
/**
- * Creates an array of own enumerable key-value pairs for `object`.
+ * Creates an array of own enumerable key-value pairs for `object` which
+ * can be consumed by `_.fromPairs`.
*
* @static
* @memberOf _
diff --git a/toPairsIn.js b/toPairsIn.js
index 778eabba0..53ea1ec9b 100644
--- a/toPairsIn.js
+++ b/toPairsIn.js
@@ -1,7 +1,8 @@
define(['./_baseToPairs', './keysIn'], function(baseToPairs, keysIn) {
/**
- * Creates an array of own and inherited enumerable key-value pairs for `object`.
+ * Creates an array of own and inherited enumerable key-value pairs for
+ * `object` which can be consumed by `_.fromPairs`.
*
* @static
* @memberOf _
diff --git a/trim.js b/trim.js
index 6173b0571..f13351f6b 100644
--- a/trim.js
+++ b/trim.js
@@ -42,7 +42,9 @@ define(['./_charsEndIndex', './_charsStartIndex', './_stringToArray', './toStrin
var strSymbols = stringToArray(string),
chrSymbols = stringToArray(chars);
- return strSymbols.slice(charsStartIndex(strSymbols, chrSymbols), charsEndIndex(strSymbols, chrSymbols) + 1).join('');
+ return strSymbols
+ .slice(charsStartIndex(strSymbols, chrSymbols), charsEndIndex(strSymbols, chrSymbols) + 1)
+ .join('');
}
return trim;
diff --git a/trimEnd.js b/trimEnd.js
index 8544879c7..e04c083bd 100644
--- a/trimEnd.js
+++ b/trimEnd.js
@@ -37,7 +37,9 @@ define(['./_charsEndIndex', './_stringToArray', './toString'], function(charsEnd
return string;
}
var strSymbols = stringToArray(string);
- return strSymbols.slice(0, charsEndIndex(strSymbols, stringToArray(chars)) + 1).join('');
+ return strSymbols
+ .slice(0, charsEndIndex(strSymbols, stringToArray(chars)) + 1)
+ .join('');
}
return trimEnd;
diff --git a/trimStart.js b/trimStart.js
index 080c99a6c..c8328e92d 100644
--- a/trimStart.js
+++ b/trimStart.js
@@ -37,7 +37,9 @@ define(['./_charsStartIndex', './_stringToArray', './toString'], function(charsS
return string;
}
var strSymbols = stringToArray(string);
- return strSymbols.slice(charsStartIndex(strSymbols, stringToArray(chars))).join('');
+ return strSymbols
+ .slice(charsStartIndex(strSymbols, stringToArray(chars)))
+ .join('');
}
return trimStart;
diff --git a/truncate.js b/truncate.js
index d2e9da641..0f83fee0b 100644
--- a/truncate.js
+++ b/truncate.js
@@ -31,7 +31,7 @@ define(['./isObject', './isRegExp', './_stringSize', './_stringToArray', './toIn
* @memberOf _
* @category String
* @param {string} [string=''] The string to truncate.
- * @param {Object} [options] The options object.
+ * @param {Object} [options=({})] The options object.
* @param {number} [options.length=30] The maximum string length.
* @param {string} [options.omission='...'] The string to indicate text is omitted.
* @param {RegExp|string} [options.separator] The separator pattern to truncate to.
diff --git a/union.js b/union.js
index de8fa5193..97758544b 100644
--- a/union.js
+++ b/union.js
@@ -16,7 +16,7 @@ define(['./_baseFlatten', './_baseUniq', './rest'], function(baseFlatten, baseUn
* // => [2, 1, 4]
*/
var union = rest(function(arrays) {
- return baseUniq(baseFlatten(arrays, false, true));
+ return baseUniq(baseFlatten(arrays, 1, true));
});
return union;
diff --git a/unionBy.js b/unionBy.js
index 4c3debeca..3fc0d36fa 100644
--- a/unionBy.js
+++ b/unionBy.js
@@ -28,7 +28,7 @@ define(['./_baseFlatten', './_baseIteratee', './_baseUniq', './isArrayLikeObject
if (isArrayLikeObject(iteratee)) {
iteratee = undefined;
}
- return baseUniq(baseFlatten(arrays, false, true), baseIteratee(iteratee));
+ return baseUniq(baseFlatten(arrays, 1, true), baseIteratee(iteratee));
});
return unionBy;
diff --git a/unionWith.js b/unionWith.js
index 72e2cd04c..3eb0f1855 100644
--- a/unionWith.js
+++ b/unionWith.js
@@ -27,7 +27,7 @@ define(['./_baseFlatten', './_baseUniq', './isArrayLikeObject', './last', './res
if (isArrayLikeObject(comparator)) {
comparator = undefined;
}
- return baseUniq(baseFlatten(arrays, false, true), undefined, comparator);
+ return baseUniq(baseFlatten(arrays, 1, true), undefined, comparator);
});
return unionWith;
diff --git a/uniqueId.js b/uniqueId.js
index 96b9973a7..77b715a78 100644
--- a/uniqueId.js
+++ b/uniqueId.js
@@ -9,7 +9,7 @@ define(['./toString'], function(toString) {
* @static
* @memberOf _
* @category Util
- * @param {string} [prefix] The value to prefix the ID with.
+ * @param {string} [prefix=''] The value to prefix the ID with.
* @returns {string} Returns the unique ID.
* @example
*
diff --git a/valuesIn.js b/valuesIn.js
index 549c56acc..c6861850f 100644
--- a/valuesIn.js
+++ b/valuesIn.js
@@ -23,7 +23,7 @@ define(['./_baseValues', './keysIn'], function(baseValues, keysIn) {
* // => [1, 2, 3] (iteration order is not guaranteed)
*/
function valuesIn(object) {
- return object == null ? baseValues(object, keysIn(object)) : [];
+ return object == null ? [] : baseValues(object, keysIn(object));
}
return valuesIn;
diff --git a/wrap.js b/wrap.js
index a41df99d3..3b9b0fe49 100644
--- a/wrap.js
+++ b/wrap.js
@@ -10,7 +10,7 @@ define(['./identity', './partial'], function(identity, partial) {
* @memberOf _
* @category Function
* @param {*} value The value to wrap.
- * @param {Function} wrapper The wrapper function.
+ * @param {Function} [wrapper=identity] The wrapper function.
* @returns {Function} Returns the new function.
* @example
*
diff --git a/wrapperAt.js b/wrapperAt.js
index ef2ae8230..a663c4c43 100644
--- a/wrapperAt.js
+++ b/wrapperAt.js
@@ -23,17 +23,22 @@ define(['./_LazyWrapper', './_LodashWrapper', './_baseAt', './_baseFlatten', './
* // => ['a', 'c']
*/
var wrapperAt = rest(function(paths) {
- paths = baseFlatten(paths);
+ paths = baseFlatten(paths, 1);
var length = paths.length,
start = length ? paths[0] : 0,
value = this.__wrapped__,
interceptor = function(object) { return baseAt(object, paths); };
- if (length > 1 || this.__actions__.length || !(value instanceof LazyWrapper) || !isIndex(start)) {
+ if (length > 1 || this.__actions__.length ||
+ !(value instanceof LazyWrapper) || !isIndex(start)) {
return this.thru(interceptor);
}
value = value.slice(start, +start + (length ? 1 : 0));
- value.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined });
+ value.__actions__.push({
+ 'func': thru,
+ 'args': [interceptor],
+ 'thisArg': undefined
+ });
return new LodashWrapper(value, this.__chain__).thru(function(array) {
if (length && !array.length) {
array.push(undefined);
diff --git a/wrapperLodash.js b/wrapperLodash.js
index ed361eb81..9b17a44f6 100644
--- a/wrapperLodash.js
+++ b/wrapperLodash.js
@@ -45,28 +45,28 @@ define(['./_LazyWrapper', './_LodashWrapper', './_baseLodash', './isArray', './i
* `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `toArray`
*
* The chainable wrapper methods are:
- * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`,
- * `at`, `before`, `bind`, `bindAll`, `bindKey`, `chain`, `chunk`, `commit`,
- * `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`, `curry`,
- * `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, `difference`,
+ * `after`, `ary`, `assign`, `assignIn`, `assignInWith`, `assignWith`, `at`,
+ * `before`, `bind`, `bindAll`, `bindKey`, `castArray`, `chain`, `chunk`,
+ * `commit`, `compact`, `concat`, `conforms`, `constant`, `countBy`, `create`,
+ * `curry`, `debounce`, `defaults`, `defaultsDeep`, `defer`, `delay`, `difference`,
* `differenceBy`, `differenceWith`, `drop`, `dropRight`, `dropRightWhile`,
- * `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flip`, `flow`,
- * `flowRight`, `fromPairs`, `functions`, `functionsIn`, `groupBy`, `initial`,
- * `intersection`, `intersectionBy`, `intersectionWith`, `invert`, `invertBy`,
- * `invokeMap`, `iteratee`, `keyBy`, `keys`, `keysIn`, `map`, `mapKeys`,
- * `mapValues`, `matches`, `matchesProperty`, `memoize`, `merge`, `mergeWith`,
- * `method`, `methodOf`, `mixin`, `negate`, `nthArg`, `omit`, `omitBy`, `once`,
- * `orderBy`, `over`, `overArgs`, `overEvery`, `overSome`, `partial`,
- * `partialRight`, `partition`, `pick`, `pickBy`, `plant`, `property`,
- * `propertyOf`, `pull`, `pullAll`, `pullAllBy`, `pullAt`, `push`, `range`,
- * `rangeRight`, `rearg`, `reject`, `remove`, `rest`, `reverse`, `sampleSize`,
- * `set`, `setWith`, `shuffle`, `slice`, `sort`, `sortBy`, `splice`, `spread`,
- * `tail`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`,
- * `thru`, `toArray`, `toPairs`, `toPairsIn`, `toPath`, `toPlainObject`,
- * `transform`, `unary`, `union`, `unionBy`, `unionWith`, `uniq`, `uniqBy`,
- * `uniqWith`, `unset`, `unshift`, `unzip`, `unzipWith`, `values`, `valuesIn`,
- * `without`, `wrap`, `xor`, `xorBy`, `xorWith`, `zip`, `zipObject`,
- * `zipObjectDeep`, and `zipWith`
+ * `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flattenDepth`,
+ * `flip`, `flow`, `flowRight`, `fromPairs`, `functions`, `functionsIn`,
+ * `groupBy`, `initial`, `intersection`, `intersectionBy`, `intersectionWith`,
+ * `invert`, `invertBy`, `invokeMap`, `iteratee`, `keyBy`, `keys`, `keysIn`,
+ * `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, `memoize`,
+ * `merge`, `mergeWith`, `method`, `methodOf`, `mixin`, `negate`, `nthArg`,
+ * `omit`, `omitBy`, `once`, `orderBy`, `over`, `overArgs`, `overEvery`,
+ * `overSome`, `partial`, `partialRight`, `partition`, `pick`, `pickBy`, `plant`,
+ * `property`, `propertyOf`, `pull`, `pullAll`, `pullAllBy`, `pullAt`, `push`,
+ * `range`, `rangeRight`, `rearg`, `reject`, `remove`, `rest`, `reverse`,
+ * `sampleSize`, `set`, `setWith`, `shuffle`, `slice`, `sort`, `sortBy`,
+ * `splice`, `spread`, `tail`, `take`, `takeRight`, `takeRightWhile`,
+ * `takeWhile`, `tap`, `throttle`, `thru`, `toArray`, `toPairs`, `toPairsIn`,
+ * `toPath`, `toPlainObject`, `transform`, `unary`, `union`, `unionBy`,
+ * `unionWith`, `uniq`, `uniqBy`, `uniqWith`, `unset`, `unshift`, `unzip`,
+ * `unzipWith`, `values`, `valuesIn`, `without`, `wrap`, `xor`, `xorBy`,
+ * `xorWith`, `zip`, `zipObject`, `zipObjectDeep`, and `zipWith`
*
* The wrapper methods that are **not** chainable by default are:
* `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clamp`, `clone`,
diff --git a/wrapperReverse.js b/wrapperReverse.js
index aac9250c7..cc9a8c8c0 100644
--- a/wrapperReverse.js
+++ b/wrapperReverse.js
@@ -30,7 +30,11 @@ define(['./_LazyWrapper', './_LodashWrapper', './reverse', './thru'], function(L
wrapped = new LazyWrapper(this);
}
wrapped = wrapped.reverse();
- wrapped.__actions__.push({ 'func': thru, 'args': [reverse], 'thisArg': undefined });
+ wrapped.__actions__.push({
+ 'func': thru,
+ 'args': [reverse],
+ 'thisArg': undefined
+ });
return new LodashWrapper(wrapped, this.__chain__);
}
return this.thru(reverse);