Compare commits

...

4 Commits

Author SHA1 Message Date
John-David Dalton
8166b65853 Bump to v4.6.0. 2016-02-29 23:38:21 -08:00
John-David Dalton
65e5d998b3 Bump to v4.5.1. 2016-02-21 20:40:07 -08:00
John-David Dalton
ae51b52aa1 Bump to v4.5.0. 2016-02-16 23:13:56 -08:00
John-David Dalton
ce259221bd Bump to v4.4.0. 2016-02-15 20:20:54 -08:00
166 changed files with 1682 additions and 949 deletions

View File

@@ -1,4 +1,4 @@
# lodash-amd v4.3.0 # lodash-amd v4.6.0
The [lodash](https://lodash.com/) library exported as [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules. 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.6.0-amd) for more details.

View File

@@ -7,6 +7,7 @@ define(['./_nativeCreate'], function(nativeCreate) {
* Creates an hash object. * Creates an hash object.
* *
* @private * @private
* @constructor
* @returns {Object} Returns the new hash object. * @returns {Object} Returns the new hash object.
*/ */
function Hash() {} function Hash() {}

View File

@@ -7,6 +7,7 @@ define(['./_baseCreate', './_baseLodash'], function(baseCreate, baseLodash) {
* Creates a lazy wrapper object which wraps `value` to enable lazy evaluation. * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
* *
* @private * @private
* @constructor
* @param {*} value The value to wrap. * @param {*} value The value to wrap.
*/ */
function LazyWrapper(value) { function LazyWrapper(value) {

View File

@@ -4,6 +4,7 @@ define(['./_mapClear', './_mapDelete', './_mapGet', './_mapHas', './_mapSet'], f
* Creates a map cache object to store key-value pairs. * Creates a map cache object to store key-value pairs.
* *
* @private * @private
* @constructor
* @param {Array} [values] The values to cache. * @param {Array} [values] The values to cache.
*/ */
function MapCache(values) { function MapCache(values) {

View File

@@ -5,6 +5,7 @@ define(['./_MapCache', './_cachePush'], function(MapCache, cachePush) {
* Creates a set cache object to store unique values. * Creates a set cache object to store unique values.
* *
* @private * @private
* @constructor
* @param {Array} [values] The values to cache. * @param {Array} [values] The values to cache.
*/ */
function SetCache(values) { function SetCache(values) {

View File

@@ -4,6 +4,7 @@ define(['./_stackClear', './_stackDelete', './_stackGet', './_stackHas', './_sta
* Creates a stack cache object to store key-value pairs. * Creates a stack cache object to store key-value pairs.
* *
* @private * @private
* @constructor
* @param {Array} [values] The values to cache. * @param {Array} [values] The values to cache.
*/ */
function Stack(values) { function Stack(values) {

View File

@@ -9,6 +9,7 @@ define([], function() {
* @returns {Object} Returns `map`. * @returns {Object} Returns `map`.
*/ */
function addMapEntry(map, pair) { function addMapEntry(map, pair) {
// Don't return `Map#set` because it doesn't return the map instance in IE 11.
map.set(pair[0], pair[1]); map.set(pair[0], pair[1]);
return map; return map;
} }

View File

@@ -12,13 +12,13 @@ define([], function() {
function arrayFilter(array, predicate) { function arrayFilter(array, predicate) {
var index = -1, var index = -1,
length = array.length, length = array.length,
resIndex = -1, resIndex = 0,
result = []; result = [];
while (++index < length) { while (++index < length) {
var value = array[index]; var value = array[index];
if (predicate(value, index, array)) { if (predicate(value, index, array)) {
result[++resIndex] = value; result[resIndex++] = value;
} }
} }
return result; return result;

View File

@@ -1,8 +1,7 @@
define([], function() { define([], function() {
/** /**
* A specialized version of `_.includesWith` for arrays without support for * This function is like `arrayIncludes` except that it accepts a comparator.
* specifying an index to search from.
* *
* @private * @private
* @param {Array} array The array to search. * @param {Array} array The array to search.

View File

@@ -4,7 +4,8 @@ define(['./eq'], function(eq) {
var undefined; var undefined;
/** /**
* This function is like `assignValue` except that it doesn't assign `undefined` values. * This function is like `assignValue` except that it doesn't assign
* `undefined` values.
* *
* @private * @private
* @param {Object} object The object to modify. * @param {Object} object The object to modify.

View File

@@ -21,8 +21,7 @@ define(['./eq'], function(eq) {
*/ */
function assignValue(object, key, value) { function assignValue(object, key, value) {
var objValue = object[key]; var objValue = object[key];
if ((!eq(objValue, value) || if (!(hasOwnProperty.call(object, key) && eq(objValue, value)) ||
(eq(objValue, objectProto[key]) && !hasOwnProperty.call(object, key))) ||
(value === undefined && !(key in object))) { (value === undefined && !(key in object))) {
object[key] = value; object[key] = value;
} }

View File

@@ -1,15 +1,15 @@
define(['./isArrayLikeObject'], function(isArrayLikeObject) { 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 * @private
* @param {*} value The value to process. * @param {*} value The value to inspect.
* @returns {Array} Returns the array-like object. * @returns {Array} Returns the array-like object.
*/ */
function toArrayLikeObject(value) { function baseCastArrayLikeObject(value) {
return isArrayLikeObject(value) ? value : []; return isArrayLikeObject(value) ? value : [];
} }
return toArrayLikeObject; return baseCastArrayLikeObject;
}); });

15
_baseCastFunction.js Normal file
View File

@@ -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;
});

15
_baseCastPath.js Normal file
View File

@@ -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;
});

View File

@@ -93,9 +93,10 @@ define(['./_Stack', './_arrayEach', './_assignValue', './_baseAssign', './_baseF
return copySymbols(value, baseAssign(result, value)); return copySymbols(value, baseAssign(result, value));
} }
} else { } else {
return cloneableTags[tag] if (!cloneableTags[tag]) {
? initCloneByTag(value, tag, isDeep) return object ? value : {};
: (object ? value : {}); }
result = initCloneByTag(value, tag, isDeep);
} }
} }
// Check for circular references and return its corresponding clone. // Check for circular references and return its corresponding clone.

View File

@@ -1,7 +1,7 @@
define(['./isObject'], function(isObject) { define(['./isObject'], function(isObject) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */ /** Built-in value references. */
var undefined; var objectCreate = Object.create;
/** /**
* The base implementation of `_.create` without support for assigning * 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. * @param {Object} prototype The object to inherit from.
* @returns {Object} Returns the new object. * @returns {Object} Returns the new object.
*/ */
var baseCreate = (function() { function baseCreate(proto) {
function object() {} return isObject(proto) ? objectCreate(proto) : {};
return function(prototype) { }
if (isObject(prototype)) {
object.prototype = prototype;
var result = new object;
object.prototype = undefined;
}
return result || {};
};
}());
return baseCreate; return baseCreate;
}); });

View File

@@ -5,12 +5,12 @@ define(['./_arrayPush', './isArguments', './isArray', './isArrayLikeObject'], fu
* *
* @private * @private
* @param {Array} array The array to flatten. * @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 {boolean} [isStrict] Restrict flattening to arrays-like objects.
* @param {Array} [result=[]] The initial result value. * @param {Array} [result=[]] The initial result value.
* @returns {Array} Returns the new flattened array. * @returns {Array} Returns the new flattened array.
*/ */
function baseFlatten(array, isDeep, isStrict, result) { function baseFlatten(array, depth, isStrict, result) {
result || (result = []); result || (result = []);
var index = -1, var index = -1,
@@ -18,11 +18,11 @@ define(['./_arrayPush', './isArguments', './isArray', './isArrayLikeObject'], fu
while (++index < length) { while (++index < length) {
var value = array[index]; var value = array[index];
if (isArrayLikeObject(value) && if (depth > 0 && isArrayLikeObject(value) &&
(isStrict || isArray(value) || isArguments(value))) { (isStrict || isArray(value) || isArguments(value))) {
if (isDeep) { if (depth > 1) {
// Recursively flatten arrays (susceptible to call stack limits). // Recursively flatten arrays (susceptible to call stack limits).
baseFlatten(value, isDeep, isStrict, result); baseFlatten(value, depth - 1, isStrict, result);
} else { } else {
arrayPush(result, value); arrayPush(result, value);
} }

View File

@@ -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. */ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined; var undefined;
@@ -12,7 +12,7 @@ define(['./_baseToPath', './_isKey'], function(baseToPath, isKey) {
* @returns {*} Returns the resolved value. * @returns {*} Returns the resolved value.
*/ */
function baseGet(object, path) { function baseGet(object, path) {
path = isKey(path, object) ? [path + ''] : baseToPath(path); path = isKey(path, object) ? [path + ''] : baseCastPath(path);
var index = 0, var index = 0,
length = path.length; length = path.length;

26
_baseIndexOfWith.js Normal file
View File

@@ -0,0 +1,26 @@
define([], function() {
/**
* This function is like `baseIndexOf` except that it accepts a comparator.
*
* @private
* @param {Array} array The array to search.
* @param {*} value The value to search for.
* @param {number} fromIndex The index to search from.
* @param {Function} comparator The comparator invoked per element.
* @returns {number} Returns the index of the matched value, else `-1`.
*/
function baseIndexOfWith(array, value, fromIndex, comparator) {
var index = fromIndex - 1,
length = array.length;
while (++index < length) {
if (comparator(array[index], value)) {
return index;
}
}
return -1;
}
return baseIndexOfWith;
});

View File

@@ -3,6 +3,9 @@ define(['./_SetCache', './_arrayIncludes', './_arrayIncludesWith', './_arrayMap'
/** Used as a safe reference for `undefined` in pre-ES5 environments. */ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined; var undefined;
/* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMin = Math.min;
/** /**
* The base implementation of methods like `_.intersection`, without support * The base implementation of methods like `_.intersection`, without support
* for iteratee shorthands, that accepts an array of arrays to inspect. * for iteratee shorthands, that accepts an array of arrays to inspect.
@@ -15,9 +18,11 @@ define(['./_SetCache', './_arrayIncludes', './_arrayIncludesWith', './_arrayMap'
*/ */
function baseIntersection(arrays, iteratee, comparator) { function baseIntersection(arrays, iteratee, comparator) {
var includes = comparator ? arrayIncludesWith : arrayIncludes, var includes = comparator ? arrayIncludesWith : arrayIncludes,
length = arrays[0].length,
othLength = arrays.length, othLength = arrays.length,
othIndex = othLength, othIndex = othLength,
caches = Array(othLength), caches = Array(othLength),
maxLength = Infinity,
result = []; result = [];
while (othIndex--) { while (othIndex--) {
@@ -25,26 +30,32 @@ define(['./_SetCache', './_arrayIncludes', './_arrayIncludesWith', './_arrayMap'
if (othIndex && iteratee) { if (othIndex && iteratee) {
array = arrayMap(array, baseUnary(iteratee)); array = arrayMap(array, baseUnary(iteratee));
} }
caches[othIndex] = !comparator && (iteratee || array.length >= 120) maxLength = nativeMin(array.length, maxLength);
caches[othIndex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
? new SetCache(othIndex && array) ? new SetCache(othIndex && array)
: undefined; : undefined;
} }
array = arrays[0]; array = arrays[0];
var index = -1, var index = -1,
length = array.length,
seen = caches[0]; seen = caches[0];
outer: outer:
while (++index < length) { while (++index < length && result.length < maxLength) {
var value = array[index], var value = array[index],
computed = iteratee ? iteratee(value) : value; computed = iteratee ? iteratee(value) : value;
if (!(seen ? cacheHas(seen, computed) : includes(result, computed, comparator))) { if (!(seen
var othIndex = othLength; ? cacheHas(seen, computed)
: includes(result, computed, comparator)
)) {
othIndex = othLength;
while (--othIndex) { while (--othIndex) {
var cache = caches[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; continue outer;
} }
} }

View File

@@ -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. */ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined; var undefined;
@@ -15,7 +15,7 @@ define(['./_apply', './_baseToPath', './_isKey', './last', './_parent'], functio
*/ */
function baseInvoke(object, path, args) { function baseInvoke(object, path, args) {
if (!isKey(path, object)) { if (!isKey(path, object)) {
path = baseToPath(path); path = baseCastPath(path);
object = parent(object, path); object = parent(object, path);
path = last(path); path = last(path);
} }

View File

@@ -36,33 +36,28 @@ define(['./_Stack', './_equalArrays', './_equalByTag', './_equalObjects', './_ge
if (!objIsArr) { if (!objIsArr) {
objTag = getTag(object); objTag = getTag(object);
if (objTag == argsTag) { objTag = objTag == argsTag ? objectTag : objTag;
objTag = objectTag;
} else if (objTag != objectTag) {
objIsArr = isTypedArray(object);
}
} }
if (!othIsArr) { if (!othIsArr) {
othTag = getTag(other); othTag = getTag(other);
if (othTag == argsTag) { othTag = othTag == argsTag ? objectTag : othTag;
othTag = objectTag;
} else if (othTag != objectTag) {
othIsArr = isTypedArray(other);
}
} }
var objIsObj = objTag == objectTag && !isHostObject(object), var objIsObj = objTag == objectTag && !isHostObject(object),
othIsObj = othTag == objectTag && !isHostObject(other), othIsObj = othTag == objectTag && !isHostObject(other),
isSameTag = objTag == othTag; isSameTag = objTag == othTag;
if (isSameTag && !(objIsArr || objIsObj)) { if (isSameTag && !objIsObj) {
return equalByTag(object, other, objTag, equalFunc, customizer, bitmask); stack || (stack = new Stack);
return (objIsArr || isTypedArray(object))
? equalArrays(object, other, equalFunc, customizer, bitmask, stack)
: equalByTag(object, other, objTag, equalFunc, customizer, bitmask, stack);
} }
var isPartial = bitmask & PARTIAL_COMPARE_FLAG; if (!(bitmask & PARTIAL_COMPARE_FLAG)) {
if (!isPartial) {
var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
if (objIsWrapped || othIsWrapped) { if (objIsWrapped || othIsWrapped) {
stack || (stack = new Stack);
return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, bitmask, stack); return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, bitmask, stack);
} }
} }
@@ -70,7 +65,7 @@ define(['./_Stack', './_equalArrays', './_equalByTag', './_equalObjects', './_ge
return false; return false;
} }
stack || (stack = new Stack); stack || (stack = new Stack);
return (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, bitmask, stack); return equalObjects(object, other, equalFunc, customizer, bitmask, stack);
} }
return baseIsEqualDeep; return baseIsEqualDeep;

View File

@@ -8,7 +8,6 @@ define([], function() {
* property of prototypes or treat sparse arrays as dense. * property of prototypes or treat sparse arrays as dense.
* *
* @private * @private
* @type Function
* @param {Object} object The object to query. * @param {Object} object The object to query.
* @returns {Array} Returns the array of property names. * @returns {Array} Returns the array of property names.
*/ */

View File

@@ -17,7 +17,10 @@ define(['./_Stack', './_arrayEach', './_assignMergeValue', './_baseMergeDeep', '
if (object === source) { if (object === source) {
return; 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) { arrayEach(props || source, function(srcValue, key) {
if (props) { if (props) {
key = srcValue; key = srcValue;
@@ -28,7 +31,10 @@ define(['./_Stack', './_arrayEach', './_assignMergeValue', './_baseMergeDeep', '
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
} }
else { 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) { if (newValue === undefined) {
newValue = srcValue; newValue = srcValue;
} }

View File

@@ -26,21 +26,24 @@ define(['./_assignMergeValue', './_baseClone', './_copyArray', './isArguments',
assignMergeValue(object, key, stacked); assignMergeValue(object, key, stacked);
return; return;
} }
var newValue = customizer ? customizer(objValue, srcValue, (key + ''), object, source, stack) : undefined, var newValue = customizer
isCommon = newValue === undefined; ? customizer(objValue, srcValue, (key + ''), object, source, stack)
: undefined;
var isCommon = newValue === undefined;
if (isCommon) { if (isCommon) {
newValue = srcValue; newValue = srcValue;
if (isArray(srcValue) || isTypedArray(srcValue)) { if (isArray(srcValue) || isTypedArray(srcValue)) {
if (isArray(objValue)) { if (isArray(objValue)) {
newValue = srcIndex ? copyArray(objValue) : objValue; newValue = objValue;
} }
else if (isArrayLikeObject(objValue)) { else if (isArrayLikeObject(objValue)) {
newValue = copyArray(objValue); newValue = copyArray(objValue);
} }
else { else {
isCommon = false; isCommon = false;
newValue = baseClone(srcValue); newValue = baseClone(srcValue, !customizer);
} }
} }
else if (isPlainObject(srcValue) || isArguments(srcValue)) { else if (isPlainObject(srcValue) || isArguments(srcValue)) {
@@ -49,10 +52,10 @@ define(['./_assignMergeValue', './_baseClone', './_copyArray', './isArguments',
} }
else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) { else if (!isObject(objValue) || (srcIndex && isFunction(objValue))) {
isCommon = false; isCommon = false;
newValue = baseClone(srcValue); newValue = baseClone(srcValue, !customizer);
} }
else { else {
newValue = srcIndex ? baseClone(objValue) : objValue; newValue = objValue;
} }
} }
else { else {
@@ -65,6 +68,7 @@ define(['./_assignMergeValue', './_baseClone', './_copyArray', './isArguments',
// Recursively merge objects and arrays (susceptible to call stack limits). // Recursively merge objects and arrays (susceptible to call stack limits).
mergeFunc(newValue, srcValue, srcIndex, customizer, stack); mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
} }
stack['delete'](srcValue);
assignMergeValue(object, key, newValue); assignMergeValue(object, key, newValue);
} }

View File

@@ -10,12 +10,8 @@ define(['./_arrayMap', './_baseIteratee', './_baseMap', './_baseSortBy', './_com
* @returns {Array} Returns the new sorted array. * @returns {Array} Returns the new sorted array.
*/ */
function baseOrderBy(collection, iteratees, orders) { function baseOrderBy(collection, iteratees, orders) {
var index = -1, var index = -1;
toIteratee = baseIteratee; iteratees = arrayMap(iteratees.length ? iteratees : Array(1), baseIteratee);
iteratees = arrayMap(iteratees.length ? iteratees : Array(1), function(iteratee) {
return toIteratee(iteratee);
});
var result = baseMap(collection, function(value, key, collection) { var result = baseMap(collection, function(value, key, collection) {
var criteria = arrayMap(iteratees, function(iteratee) { var criteria = arrayMap(iteratees, function(iteratee) {

View File

@@ -1,15 +1,44 @@
define(['./_basePullAllBy'], function(basePullAllBy) { define(['./_arrayMap', './_baseIndexOf', './_baseIndexOfWith', './_baseUnary'], function(arrayMap, baseIndexOf, baseIndexOfWith, baseUnary) {
/** Used for built-in method references. */
var arrayProto = Array.prototype;
/** Built-in value references. */
var splice = arrayProto.splice;
/** /**
* The base implementation of `_.pullAll`. * The base implementation of `_.pullAllBy` without support for iteratee
* shorthands.
* *
* @private * @private
* @param {Array} array The array to modify. * @param {Array} array The array to modify.
* @param {Array} values The values to remove. * @param {Array} values The values to remove.
* @param {Function} [iteratee] The iteratee invoked per element.
* @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns `array`. * @returns {Array} Returns `array`.
*/ */
function basePullAll(array, values) { function basePullAll(array, values, iteratee, comparator) {
return basePullAllBy(array, values); var indexOf = comparator ? baseIndexOfWith : baseIndexOf,
index = -1,
length = values.length,
seen = array;
if (iteratee) {
seen = arrayMap(array, baseUnary(iteratee));
}
while (++index < length) {
var fromIndex = 0,
value = values[index],
computed = iteratee ? iteratee(value) : value;
while ((fromIndex = indexOf(seen, computed, fromIndex, comparator)) > -1) {
if (seen !== array) {
splice.call(seen, fromIndex, 1);
}
splice.call(array, fromIndex, 1);
}
}
return array;
} }
return basePullAll; return basePullAll;

View File

@@ -1,43 +0,0 @@
define(['./_arrayMap', './_baseIndexOf'], function(arrayMap, baseIndexOf) {
/** Used for built-in method references. */
var arrayProto = Array.prototype;
/** Built-in value references. */
var splice = arrayProto.splice;
/**
* The base implementation of `_.pullAllBy` without support for iteratee
* shorthands.
*
* @private
* @param {Array} array The array to modify.
* @param {Array} values The values to remove.
* @param {Function} [iteratee] The iteratee invoked per element.
* @returns {Array} Returns `array`.
*/
function basePullAllBy(array, values, iteratee) {
var index = -1,
length = values.length,
seen = array;
if (iteratee) {
seen = arrayMap(array, function(value) { return iteratee(value); });
}
while (++index < length) {
var fromIndex = 0,
value = values[index],
computed = iteratee ? iteratee(value) : value;
while ((fromIndex = baseIndexOf(seen, computed, fromIndex)) > -1) {
if (seen !== array) {
splice.call(seen, fromIndex, 1);
}
splice.call(array, fromIndex, 1);
}
}
return array;
}
return basePullAllBy;
});

View File

@@ -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. */ /** Used for built-in method references. */
var arrayProto = Array.prototype; var arrayProto = Array.prototype;
@@ -27,7 +27,7 @@ define(['./_baseToPath', './_isIndex', './_isKey', './last', './_parent'], funct
splice.call(array, index, 1); splice.call(array, index, 1);
} }
else if (!isKey(index, array)) { else if (!isKey(index, array)) {
var path = baseToPath(index), var path = baseCastPath(index),
object = parent(array, path); object = parent(array, path);
if (object != null) { if (object != null) {

View File

@@ -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. */ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined; var undefined;
@@ -14,7 +14,7 @@ define(['./_assignValue', './_baseToPath', './_isIndex', './_isKey', './isObject
* @returns {Object} Returns `object`. * @returns {Object} Returns `object`.
*/ */
function baseSet(object, path, value, customizer) { function baseSet(object, path, value, customizer) {
path = isKey(path, object) ? [path + ''] : baseToPath(path); path = isKey(path, object) ? [path + ''] : baseCastPath(path);
var index = -1, var index = -1,
length = path.length, length = path.length,
@@ -29,7 +29,9 @@ define(['./_assignValue', './_baseToPath', './_isIndex', './_isKey', './isObject
var objValue = nested[key]; var objValue = nested[key];
newValue = customizer ? customizer(objValue, key, nested) : undefined; newValue = customizer ? customizer(objValue, key, nested) : undefined;
if (newValue === undefined) { if (newValue === undefined) {
newValue = objValue == null ? (isIndex(path[index + 1]) ? [] : {}) : objValue; newValue = objValue == null
? (isIndex(path[index + 1]) ? [] : {})
: objValue;
} }
} }
assignValue(nested, key, newValue); assignValue(nested, key, newValue);

View File

@@ -1,9 +1,9 @@
define([], function() { define([], function() {
/** /**
* The base implementation of `_.sortBy` which uses `comparer` to define * The base implementation of `_.sortBy` which uses `comparer` to define the
* the sort order of `array` and replaces criteria objects with their * sort order of `array` and replaces criteria objects with their corresponding
* corresponding values. * values.
* *
* @private * @private
* @param {Array} array The array to sort. * @param {Array} array The array to sort.

View File

@@ -15,7 +15,7 @@ define(['./eq'], function(eq) {
value = array[0], value = array[0],
computed = iteratee ? iteratee(value) : value, computed = iteratee ? iteratee(value) : value,
seen = computed, seen = computed,
resIndex = 0, resIndex = 1,
result = [value]; result = [value];
while (++index < length) { while (++index < length) {
@@ -24,7 +24,7 @@ define(['./eq'], function(eq) {
if (!eq(computed, seen)) { if (!eq(computed, seen)) {
seen = computed; seen = computed;
result[++resIndex] = value; result[resIndex++] = value;
} }
} }
return result; return result;

View File

@@ -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;
});

View File

@@ -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`. * 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`. * @returns {boolean} Returns `true` if the property is deleted, else `false`.
*/ */
function baseUnset(object, path) { function baseUnset(object, path) {
path = isKey(path, object) ? [path + ''] : baseToPath(path); path = isKey(path, object) ? [path + ''] : baseCastPath(path);
object = parent(object, path); object = parent(object, path);
var key = last(path); var key = last(path);
return (object != null && has(object, key)) ? delete object[key] : true; return (object != null && has(object, key)) ? delete object[key] : true;

18
_baseUpdate.js Normal file
View File

@@ -0,0 +1,18 @@
define(['./_baseGet', './_baseSet'], function(baseGet, baseSet) {
/**
* The base implementation of `_.update`.
*
* @private
* @param {Object} object The object to query.
* @param {Array|string} path The path of the property to update.
* @param {Function} updater The function to produce the updated value.
* @param {Function} [customizer] The function to customize path creation.
* @returns {Object} Returns `object`.
*/
function baseUpdate(object, path, updater, customizer) {
return baseSet(object, path, updater(baseGet(object, path)), customizer);
}
return baseUpdate;
});

View File

@@ -8,11 +8,8 @@ define(['./_Uint8Array'], function(Uint8Array) {
* @returns {ArrayBuffer} Returns the cloned array buffer. * @returns {ArrayBuffer} Returns the cloned array buffer.
*/ */
function cloneArrayBuffer(arrayBuffer) { function cloneArrayBuffer(arrayBuffer) {
var Ctor = arrayBuffer.constructor, var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
result = new Ctor(arrayBuffer.byteLength), new Uint8Array(result).set(new Uint8Array(arrayBuffer));
view = new Uint8Array(result);
view.set(new Uint8Array(arrayBuffer));
return result; return result;
} }

View File

@@ -12,9 +12,7 @@ define([], function() {
if (isDeep) { if (isDeep) {
return buffer.slice(); return buffer.slice();
} }
var Ctor = buffer.constructor, var result = new buffer.constructor(buffer.length);
result = new Ctor(buffer.length);
buffer.copy(result); buffer.copy(result);
return result; return result;
} }

View File

@@ -8,8 +8,7 @@ define(['./_addMapEntry', './_arrayReduce', './_mapToArray'], function(addMapEnt
* @returns {Object} Returns the cloned map. * @returns {Object} Returns the cloned map.
*/ */
function cloneMap(map) { function cloneMap(map) {
var Ctor = map.constructor; return arrayReduce(mapToArray(map), addMapEntry, new map.constructor);
return arrayReduce(mapToArray(map), addMapEntry, new Ctor);
} }
return cloneMap; return cloneMap;

View File

@@ -11,9 +11,7 @@ define([], function() {
* @returns {Object} Returns the cloned regexp. * @returns {Object} Returns the cloned regexp.
*/ */
function cloneRegExp(regexp) { function cloneRegExp(regexp) {
var Ctor = regexp.constructor, var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
result = new Ctor(regexp.source, reFlags.exec(regexp));
result.lastIndex = regexp.lastIndex; result.lastIndex = regexp.lastIndex;
return result; return result;
} }

View File

@@ -8,8 +8,7 @@ define(['./_addSetEntry', './_arrayReduce', './_setToArray'], function(addSetEnt
* @returns {Object} Returns the cloned set. * @returns {Object} Returns the cloned set.
*/ */
function cloneSet(set) { function cloneSet(set) {
var Ctor = set.constructor; return arrayReduce(setToArray(set), addSetEntry, new set.constructor);
return arrayReduce(setToArray(set), addSetEntry, new Ctor);
} }
return cloneSet; return cloneSet;

View File

@@ -5,7 +5,7 @@ define(['./_Symbol'], function(Symbol) {
/** Used to convert symbols to primitives and strings. */ /** Used to convert symbols to primitives and strings. */
var symbolProto = Symbol ? Symbol.prototype : undefined, var symbolProto = Symbol ? Symbol.prototype : undefined,
symbolValueOf = Symbol ? symbolProto.valueOf : undefined; symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
/** /**
* Creates a clone of the `symbol` object. * Creates a clone of the `symbol` object.
@@ -15,7 +15,7 @@ define(['./_Symbol'], function(Symbol) {
* @returns {Object} Returns the cloned symbol object. * @returns {Object} Returns the cloned symbol object.
*/ */
function cloneSymbol(symbol) { function cloneSymbol(symbol) {
return Symbol ? Object(symbolValueOf.call(symbol)) : {}; return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
} }
return cloneSymbol; return cloneSymbol;

View File

@@ -9,10 +9,8 @@ define(['./_cloneArrayBuffer'], function(cloneArrayBuffer) {
* @returns {Object} Returns the cloned typed array. * @returns {Object} Returns the cloned typed array.
*/ */
function cloneTypedArray(typedArray, isDeep) { function cloneTypedArray(typedArray, isDeep) {
var buffer = typedArray.buffer, var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
Ctor = typedArray.constructor; return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
return new Ctor(isDeep ? cloneArrayBuffer(buffer) : buffer, typedArray.byteOffset, typedArray.length);
} }
return cloneTypedArray; return cloneTypedArray;

View File

@@ -11,23 +11,28 @@ define([], function() {
* @param {Array|Object} args The provided arguments. * @param {Array|Object} args The provided arguments.
* @param {Array} partials The arguments to prepend to those provided. * @param {Array} partials The arguments to prepend to those provided.
* @param {Array} holders The `partials` placeholder indexes. * @param {Array} holders The `partials` placeholder indexes.
* @params {boolean} [isCurried] Specify composing for a curried function.
* @returns {Array} Returns the new array of composed arguments. * @returns {Array} Returns the new array of composed arguments.
*/ */
function composeArgs(args, partials, holders) { function composeArgs(args, partials, holders, isCurried) {
var holdersLength = holders.length, var argsIndex = -1,
argsIndex = -1, argsLength = args.length,
argsLength = nativeMax(args.length - holdersLength, 0), holdersLength = holders.length,
leftIndex = -1, leftIndex = -1,
leftLength = partials.length, leftLength = partials.length,
result = Array(leftLength + argsLength); rangeLength = nativeMax(argsLength - holdersLength, 0),
result = Array(leftLength + rangeLength),
isUncurried = !isCurried;
while (++leftIndex < leftLength) { while (++leftIndex < leftLength) {
result[leftIndex] = partials[leftIndex]; result[leftIndex] = partials[leftIndex];
} }
while (++argsIndex < holdersLength) { while (++argsIndex < holdersLength) {
result[holders[argsIndex]] = args[argsIndex]; if (isUncurried || argsIndex < argsLength) {
result[holders[argsIndex]] = args[argsIndex];
}
} }
while (argsLength--) { while (rangeLength--) {
result[leftIndex++] = args[argsIndex++]; result[leftIndex++] = args[argsIndex++];
} }
return result; return result;

View File

@@ -11,18 +11,21 @@ define([], function() {
* @param {Array|Object} args The provided arguments. * @param {Array|Object} args The provided arguments.
* @param {Array} partials The arguments to append to those provided. * @param {Array} partials The arguments to append to those provided.
* @param {Array} holders The `partials` placeholder indexes. * @param {Array} holders The `partials` placeholder indexes.
* @params {boolean} [isCurried] Specify composing for a curried function.
* @returns {Array} Returns the new array of composed arguments. * @returns {Array} Returns the new array of composed arguments.
*/ */
function composeArgsRight(args, partials, holders) { function composeArgsRight(args, partials, holders, isCurried) {
var holdersIndex = -1, var argsIndex = -1,
argsLength = args.length,
holdersIndex = -1,
holdersLength = holders.length, holdersLength = holders.length,
argsIndex = -1,
argsLength = nativeMax(args.length - holdersLength, 0),
rightIndex = -1, rightIndex = -1,
rightLength = partials.length, rightLength = partials.length,
result = Array(argsLength + rightLength); rangeLength = nativeMax(argsLength - holdersLength, 0),
result = Array(rangeLength + rightLength),
isUncurried = !isCurried;
while (++argsIndex < argsLength) { while (++argsIndex < rangeLength) {
result[argsIndex] = args[argsIndex]; result[argsIndex] = args[argsIndex];
} }
var offset = argsIndex; var offset = argsIndex;
@@ -30,7 +33,9 @@ define([], function() {
result[offset + rightIndex] = partials[rightIndex]; result[offset + rightIndex] = partials[rightIndex];
} }
while (++holdersIndex < holdersLength) { while (++holdersIndex < holdersLength) {
result[offset + holders[holdersIndex]] = args[argsIndex++]; if (isUncurried || argsIndex < argsLength) {
result[offset + holders[holdersIndex]] = args[argsIndex++];
}
} }
return result; return result;
} }

View File

@@ -18,8 +18,11 @@ define(['./_assignValue'], function(assignValue) {
length = props.length; length = props.length;
while (++index < length) { while (++index < length) {
var key = props[index], var key = props[index];
newValue = customizer ? customizer(object[key], source[key], key, object, source) : source[key];
var newValue = customizer
? customizer(object[key], source[key], key, object, source)
: source[key];
assignValue(object, key, newValue); assignValue(object, key, newValue);
} }

24
_countHolders.js Normal file
View File

@@ -0,0 +1,24 @@
define([], function() {
/**
* Gets the number of `placeholder` occurrences in `array`.
*
* @private
* @param {Array} array The array to inspect.
* @param {*} placeholder The placeholder to search for.
* @returns {number} Returns the placeholder count.
*/
function countHolders(array, placeholder) {
var length = array.length,
result = 0;
while (length--) {
if (array[length] === placeholder) {
result++;
}
}
return result;
}
return countHolders;
});

View File

@@ -17,7 +17,10 @@ define(['./_isIterateeCall', './rest'], function(isIterateeCall, rest) {
customizer = length > 1 ? sources[length - 1] : undefined, customizer = length > 1 ? sources[length - 1] : undefined,
guard = length > 2 ? sources[2] : 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)) { if (guard && isIterateeCall(sources[0], sources[1], guard)) {
customizer = length < 3 ? undefined : customizer; customizer = length < 3 ? undefined : customizer;
length = 1; length = 1;

View File

@@ -26,8 +26,11 @@ define(['./_stringToArray', './toString'], function(stringToArray, toString) {
return function(string) { return function(string) {
string = toString(string); string = toString(string);
var strSymbols = reHasComplexSymbol.test(string) ? stringToArray(string) : undefined, var strSymbols = reHasComplexSymbol.test(string)
chr = strSymbols ? strSymbols[0] : string.charAt(0), ? stringToArray(string)
: undefined;
var chr = strSymbols ? strSymbols[0] : string.charAt(0),
trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1); trailing = strSymbols ? strSymbols.slice(1).join('') : string.slice(1);
return chr[methodName]() + trailing; return chr[methodName]() + trailing;

View File

@@ -1,4 +1,4 @@
define(['./_apply', './_createCtorWrapper', './_createHybridWrapper', './_createRecurryWrapper', './_replaceHolders', './_root'], function(apply, createCtorWrapper, createHybridWrapper, createRecurryWrapper, replaceHolders, root) { define(['./_apply', './_createCtorWrapper', './_createHybridWrapper', './_createRecurryWrapper', './_getPlaceholder', './_replaceHolders', './_root'], function(apply, createCtorWrapper, createHybridWrapper, createRecurryWrapper, getPlaceholder, replaceHolders, root) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined; var undefined;
@@ -17,10 +17,9 @@ define(['./_apply', './_createCtorWrapper', './_createHybridWrapper', './_create
function wrapper() { function wrapper() {
var length = arguments.length, var length = arguments.length,
index = length,
args = Array(length), args = Array(length),
fn = (this && this !== root && this instanceof wrapper) ? Ctor : func, index = length,
placeholder = wrapper.placeholder; placeholder = getPlaceholder(wrapper);
while (index--) { while (index--) {
args[index] = arguments[index]; args[index] = arguments[index];
@@ -30,9 +29,13 @@ define(['./_apply', './_createCtorWrapper', './_createHybridWrapper', './_create
: replaceHolders(args, placeholder); : replaceHolders(args, placeholder);
length -= holders.length; length -= holders.length;
return length < arity if (length < arity) {
? createRecurryWrapper(func, bitmask, createHybridWrapper, placeholder, undefined, args, holders, undefined, undefined, arity - length) return createRecurryWrapper(
: apply(fn, this, args); func, bitmask, createHybridWrapper, wrapper.placeholder, undefined,
args, holders, undefined, undefined, arity - length);
}
var fn = (this && this !== root && this instanceof wrapper) ? Ctor : func;
return apply(fn, this, args);
} }
return wrapper; return wrapper;
} }

View File

@@ -3,18 +3,18 @@ define(['./_LodashWrapper', './_baseFlatten', './_getData', './_getFuncName', '.
/** Used as a safe reference for `undefined` in pre-ES5 environments. */ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined; var undefined;
/** Used to compose bitmasks for wrapper metadata. */
var CURRY_FLAG = 8,
PARTIAL_FLAG = 32,
ARY_FLAG = 128,
REARG_FLAG = 256;
/** Used as the size to enable large array optimizations. */ /** Used as the size to enable large array optimizations. */
var LARGE_ARRAY_SIZE = 200; var LARGE_ARRAY_SIZE = 200;
/** Used as the `TypeError` message for "Functions" methods. */ /** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function'; var FUNC_ERROR_TEXT = 'Expected a function';
/** Used to compose bitmasks for wrapper metadata. */
var CURRY_FLAG = 8,
PARTIAL_FLAG = 32,
ARY_FLAG = 128,
REARG_FLAG = 256;
/** /**
* Creates a `_.flow` or `_.flowRight` function. * Creates a `_.flow` or `_.flowRight` function.
* *
@@ -24,7 +24,7 @@ define(['./_LodashWrapper', './_baseFlatten', './_getData', './_getFuncName', '.
*/ */
function createFlow(fromRight) { function createFlow(fromRight) {
return rest(function(funcs) { return rest(function(funcs) {
funcs = baseFlatten(funcs); funcs = baseFlatten(funcs, 1);
var length = funcs.length, var length = funcs.length,
index = length, index = length,
@@ -49,7 +49,10 @@ define(['./_LodashWrapper', './_baseFlatten', './_getData', './_getFuncName', '.
var funcName = getFuncName(func), var funcName = getFuncName(func),
data = funcName == 'wrapper' ? getData(func) : undefined; 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]); wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
} else { } else {
wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func); wrapper = (func.length == 1 && isLaziable(func)) ? wrapper[funcName]() : wrapper.thru(func);
@@ -59,7 +62,8 @@ define(['./_LodashWrapper', './_baseFlatten', './_getData', './_getFuncName', '.
var args = arguments, var args = arguments,
value = args[0]; 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(); return wrapper.plant(value).value();
} }
var index = 0, var index = 0,

View File

@@ -1,4 +1,4 @@
define(['./_composeArgs', './_composeArgsRight', './_createCtorWrapper', './_createRecurryWrapper', './_reorder', './_replaceHolders', './_root'], function(composeArgs, composeArgsRight, createCtorWrapper, createRecurryWrapper, reorder, replaceHolders, root) { define(['./_composeArgs', './_composeArgsRight', './_countHolders', './_createCtorWrapper', './_createRecurryWrapper', './_getPlaceholder', './_reorder', './_replaceHolders', './_root'], function(composeArgs, composeArgsRight, countHolders, createCtorWrapper, createRecurryWrapper, getPlaceholder, reorder, replaceHolders, root) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined; var undefined;
@@ -32,8 +32,7 @@ define(['./_composeArgs', './_composeArgsRight', './_createCtorWrapper', './_cre
var isAry = bitmask & ARY_FLAG, var isAry = bitmask & ARY_FLAG,
isBind = bitmask & BIND_FLAG, isBind = bitmask & BIND_FLAG,
isBindKey = bitmask & BIND_KEY_FLAG, isBindKey = bitmask & BIND_KEY_FLAG,
isCurry = bitmask & CURRY_FLAG, isCurried = bitmask & (CURRY_FLAG | CURRY_RIGHT_FLAG),
isCurryRight = bitmask & CURRY_RIGHT_FLAG,
isFlip = bitmask & FLIP_FLAG, isFlip = bitmask & FLIP_FLAG,
Ctor = isBindKey ? undefined : createCtorWrapper(func); Ctor = isBindKey ? undefined : createCtorWrapper(func);
@@ -45,30 +44,34 @@ define(['./_composeArgs', './_composeArgsRight', './_createCtorWrapper', './_cre
while (index--) { while (index--) {
args[index] = arguments[index]; args[index] = arguments[index];
} }
if (isCurried) {
var placeholder = getPlaceholder(wrapper),
holdersCount = countHolders(args, placeholder);
}
if (partials) { if (partials) {
args = composeArgs(args, partials, holders); args = composeArgs(args, partials, holders, isCurried);
} }
if (partialsRight) { if (partialsRight) {
args = composeArgsRight(args, partialsRight, holdersRight); args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
} }
if (isCurry || isCurryRight) { length -= holdersCount;
var placeholder = wrapper.placeholder, if (isCurried && length < arity) {
argsHolders = replaceHolders(args, placeholder); var newHolders = replaceHolders(args, placeholder);
return createRecurryWrapper(
length -= argsHolders.length; func, bitmask, createHybridWrapper, wrapper.placeholder, thisArg,
if (length < arity) { args, newHolders, argPos, ary, arity - length
return createRecurryWrapper(func, bitmask, createHybridWrapper, placeholder, thisArg, args, argsHolders, argPos, ary, arity - length); );
}
} }
var thisBinding = isBind ? thisArg : this, var thisBinding = isBind ? thisArg : this,
fn = isBindKey ? thisBinding[func] : func; fn = isBindKey ? thisBinding[func] : func;
length = args.length;
if (argPos) { if (argPos) {
args = reorder(args, argPos); args = reorder(args, argPos);
} else if (isFlip && args.length > 1) { } else if (isFlip && length > 1) {
args.reverse(); args.reverse();
} }
if (isAry && ary < args.length) { if (isAry && ary < length) {
args.length = ary; args.length = ary;
} }
if (this && this !== root && this instanceof wrapper) { if (this && this !== root && this instanceof wrapper) {

View File

@@ -9,7 +9,7 @@ define(['./_apply', './_arrayMap', './_baseFlatten', './_baseIteratee', './rest'
*/ */
function createOver(arrayFunc) { function createOver(arrayFunc) {
return rest(function(iteratees) { return rest(function(iteratees) {
iteratees = arrayMap(baseFlatten(iteratees), baseIteratee); iteratees = arrayMap(baseFlatten(iteratees, 1), baseIteratee);
return rest(function(args) { return rest(function(args) {
var thisArg = this; var thisArg = this;
return arrayFunc(iteratees, function(iteratee) { return arrayFunc(iteratees, function(iteratee) {

View File

@@ -18,7 +18,7 @@ define(['./_copyArray', './_isLaziable', './_setData'], function(copyArray, isLa
* @param {Function} func The function to wrap. * @param {Function} func The function to wrap.
* @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details. * @param {number} bitmask The bitmask of wrapper flags. See `createWrapper` for more details.
* @param {Function} wrapFunc The function to create the `func` wrapper. * @param {Function} wrapFunc The function to create the `func` wrapper.
* @param {*} placeholder The placeholder to replace. * @param {*} placeholder The placeholder value.
* @param {*} [thisArg] The `this` binding of `func`. * @param {*} [thisArg] The `this` binding of `func`.
* @param {Array} [partials] The arguments to prepend to those provided to the new function. * @param {Array} [partials] The arguments to prepend to those provided to the new function.
* @param {Array} [holders] The `partials` placeholder indexes. * @param {Array} [holders] The `partials` placeholder indexes.
@@ -30,7 +30,7 @@ define(['./_copyArray', './_isLaziable', './_setData'], function(copyArray, isLa
function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) { function createRecurryWrapper(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary, arity) {
var isCurry = bitmask & CURRY_FLAG, var isCurry = bitmask & CURRY_FLAG,
newArgPos = argPos ? copyArray(argPos) : undefined, newArgPos = argPos ? copyArray(argPos) : undefined,
newsHolders = isCurry ? holders : undefined, newHolders = isCurry ? holders : undefined,
newHoldersRight = isCurry ? undefined : holders, newHoldersRight = isCurry ? undefined : holders,
newPartials = isCurry ? partials : undefined, newPartials = isCurry ? partials : undefined,
newPartialsRight = isCurry ? undefined : partials; newPartialsRight = isCurry ? undefined : partials;
@@ -41,9 +41,12 @@ define(['./_copyArray', './_isLaziable', './_setData'], function(copyArray, isLa
if (!(bitmask & CURRY_BOUND_FLAG)) { if (!(bitmask & CURRY_BOUND_FLAG)) {
bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG); bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
} }
var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, arity], var newData = [
result = wrapFunc.apply(undefined, newData); func, bitmask, thisArg, newPartials, newHolders, newPartialsRight,
newHoldersRight, newArgPos, ary, arity
];
var result = wrapFunc.apply(undefined, newData);
if (isLaziable(func)) { if (isLaziable(func)) {
setData(result, newData); setData(result, newData);
} }

View File

@@ -3,6 +3,9 @@ define(['./_baseSetData', './_createBaseWrapper', './_createCurryWrapper', './_c
/** Used as a safe reference for `undefined` in pre-ES5 environments. */ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined; var undefined;
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/** Used to compose bitmasks for wrapper metadata. */ /** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1, var BIND_FLAG = 1,
BIND_KEY_FLAG = 2, BIND_KEY_FLAG = 2,
@@ -11,9 +14,6 @@ define(['./_baseSetData', './_createBaseWrapper', './_createCurryWrapper', './_c
PARTIAL_FLAG = 32, PARTIAL_FLAG = 32,
PARTIAL_RIGHT_FLAG = 64; PARTIAL_RIGHT_FLAG = 64;
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/* Built-in method references for those with the same name as other `lodash` methods. */ /* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max; var nativeMax = Math.max;
@@ -62,8 +62,12 @@ define(['./_baseSetData', './_createBaseWrapper', './_createCurryWrapper', './_c
partials = holders = undefined; partials = holders = undefined;
} }
var data = isBindKey ? undefined : getData(func), var data = isBindKey ? undefined : getData(func);
newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity];
var newData = [
func, bitmask, thisArg, partials, holders, partialsRight, holdersRight,
argPos, ary, arity
];
if (data) { if (data) {
mergeData(newData, data); mergeData(newData, data);

View File

@@ -15,9 +15,9 @@ define(['./_arraySome'], function(arraySome) {
* @param {Array} array The array to compare. * @param {Array} array The array to compare.
* @param {Array} other The other array to compare. * @param {Array} other The other array to compare.
* @param {Function} equalFunc The function to determine equivalents of values. * @param {Function} equalFunc The function to determine equivalents of values.
* @param {Function} [customizer] The function to customize comparisons. * @param {Function} customizer The function to customize comparisons.
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` for more details. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` for more details.
* @param {Object} [stack] Tracks traversed `array` and `other` objects. * @param {Object} stack Tracks traversed `array` and `other` objects.
* @returns {boolean} Returns `true` if the arrays are equivalent, else `false`. * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
*/ */
function equalArrays(array, other, equalFunc, customizer, bitmask, stack) { function equalArrays(array, other, equalFunc, customizer, bitmask, stack) {

View File

@@ -1,4 +1,4 @@
define(['./_Symbol', './_Uint8Array', './_mapToArray', './_setToArray'], function(Symbol, Uint8Array, mapToArray, setToArray) { define(['./_Symbol', './_Uint8Array', './_equalArrays', './_mapToArray', './_setToArray'], function(Symbol, Uint8Array, equalArrays, mapToArray, setToArray) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined; var undefined;
@@ -22,7 +22,7 @@ define(['./_Symbol', './_Uint8Array', './_mapToArray', './_setToArray'], functio
/** Used to convert symbols to primitives and strings. */ /** Used to convert symbols to primitives and strings. */
var symbolProto = Symbol ? Symbol.prototype : undefined, var symbolProto = Symbol ? Symbol.prototype : undefined,
symbolValueOf = Symbol ? symbolProto.valueOf : undefined; symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
/** /**
* A specialized version of `baseIsEqualDeep` for comparing objects of * A specialized version of `baseIsEqualDeep` for comparing objects of
@@ -36,11 +36,12 @@ define(['./_Symbol', './_Uint8Array', './_mapToArray', './_setToArray'], functio
* @param {Object} other The other object to compare. * @param {Object} other The other object to compare.
* @param {string} tag The `toStringTag` of the objects to compare. * @param {string} tag The `toStringTag` of the objects to compare.
* @param {Function} equalFunc The function to determine equivalents of values. * @param {Function} equalFunc The function to determine equivalents of values.
* @param {Function} [customizer] The function to customize comparisons. * @param {Function} customizer The function to customize comparisons.
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` for more details. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` for more details.
* @param {Object} stack Tracks traversed `object` and `other` objects.
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
*/ */
function equalByTag(object, other, tag, equalFunc, customizer, bitmask) { function equalByTag(object, other, tag, equalFunc, customizer, bitmask, stack) {
switch (tag) { switch (tag) {
case arrayBufferTag: case arrayBufferTag:
if ((object.byteLength != other.byteLength) || if ((object.byteLength != other.byteLength) ||
@@ -75,12 +76,21 @@ define(['./_Symbol', './_Uint8Array', './_mapToArray', './_setToArray'], functio
var isPartial = bitmask & PARTIAL_COMPARE_FLAG; var isPartial = bitmask & PARTIAL_COMPARE_FLAG;
convert || (convert = setToArray); convert || (convert = setToArray);
if (object.size != other.size && !isPartial) {
return false;
}
// Assume cyclic values are equal.
var stacked = stack.get(object);
if (stacked) {
return stacked == other;
}
// Recursively compare objects (susceptible to call stack limits). // Recursively compare objects (susceptible to call stack limits).
return (isPartial || object.size == other.size) && return equalArrays(convert(object), convert(other), equalFunc, customizer, bitmask | UNORDERED_COMPARE_FLAG, stack.set(object, other));
equalFunc(convert(object), convert(other), customizer, bitmask | UNORDERED_COMPARE_FLAG);
case symbolTag: case symbolTag:
return !!Symbol && (symbolValueOf.call(object) == symbolValueOf.call(other)); if (symbolValueOf) {
return symbolValueOf.call(object) == symbolValueOf.call(other);
}
} }
return false; return false;
} }

View File

@@ -14,9 +14,9 @@ define(['./_baseHas', './keys'], function(baseHas, keys) {
* @param {Object} object The object to compare. * @param {Object} object The object to compare.
* @param {Object} other The other object to compare. * @param {Object} other The other object to compare.
* @param {Function} equalFunc The function to determine equivalents of values. * @param {Function} equalFunc The function to determine equivalents of values.
* @param {Function} [customizer] The function to customize comparisons. * @param {Function} customizer The function to customize comparisons.
* @param {number} [bitmask] The bitmask of comparison flags. See `baseIsEqual` for more details. * @param {number} bitmask The bitmask of comparison flags. See `baseIsEqual` for more details.
* @param {Object} [stack] Tracks traversed `object` and `other` objects. * @param {Object} stack Tracks traversed `object` and `other` objects.
* @returns {boolean} Returns `true` if the objects are equivalent, else `false`. * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
*/ */
function equalObjects(object, other, equalFunc, customizer, bitmask, stack) { function equalObjects(object, other, equalFunc, customizer, bitmask, stack) {

View File

@@ -12,7 +12,7 @@ define(['./isNative'], function(isNative) {
* @returns {*} Returns the function if it's native, else `undefined`. * @returns {*} Returns the function if it's native, else `undefined`.
*/ */
function getNative(object, key) { function getNative(object, key) {
var value = object == null ? undefined : object[key]; var value = object[key];
return isNative(value) ? value : undefined; return isNative(value) ? value : undefined;
} }

16
_getPlaceholder.js Normal file
View File

@@ -0,0 +1,16 @@
define([], function() {
/**
* Gets the argument placeholder value for `func`.
*
* @private
* @param {Function} func The function to inspect.
* @returns {*} Returns the placeholder value.
*/
function getPlaceholder(func) {
var object = func;
return object.placeholder;
}
return getPlaceholder;
});

View File

@@ -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. */ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined; var undefined;
@@ -18,7 +18,7 @@ define(['./_baseToPath', './isArguments', './isArray', './_isIndex', './_isKey',
} }
var result = hasFunc(object, path); var result = hasFunc(object, path);
if (!result && !isKey(path)) { if (!result && !isKey(path)) {
path = baseToPath(path); path = baseCastPath(path);
object = parent(object, path); object = parent(object, path);
if (object != null) { if (object != null) {
path = last(path); path = last(path);

View File

@@ -1,7 +1,7 @@
define(['./_baseCreate', './isFunction', './_isPrototype'], function(baseCreate, isFunction, isPrototype) { define(['./_baseCreate', './_isPrototype'], function(baseCreate, isPrototype) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */ /** Built-in value references. */
var undefined; var getPrototypeOf = Object.getPrototypeOf;
/** /**
* Initializes an object clone. * Initializes an object clone.
@@ -11,11 +11,9 @@ define(['./_baseCreate', './isFunction', './_isPrototype'], function(baseCreate,
* @returns {Object} Returns the initialized clone. * @returns {Object} Returns the initialized clone.
*/ */
function initCloneObject(object) { function initCloneObject(object) {
if (isPrototype(object)) { return (typeof object.constructor == 'function' && !isPrototype(object))
return {}; ? baseCreate(getPrototypeOf(object))
} : {};
var Ctor = object.constructor;
return baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined);
} }
return initCloneObject; return initCloneObject;

View File

@@ -10,7 +10,7 @@ define([], function() {
function isKeyable(value) { function isKeyable(value) {
var type = typeof value; var type = typeof value;
return type == 'number' || type == 'boolean' || return type == 'number' || type == 'boolean' ||
(type == 'string' && value !== '__proto__') || value == null; (type == 'string' && value != '__proto__') || value == null;
} }
return isKeyable; return isKeyable;

View File

@@ -34,7 +34,8 @@ define(['./_baseWrapperValue', './_getView', './isArray'], function(baseWrapperV
resIndex = 0, resIndex = 0,
takeCount = nativeMin(length, this.__takeCount__); 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__); return baseWrapperValue(array, this.__actions__);
} }
var result = []; var result = [];

View File

@@ -8,7 +8,11 @@ define(['./_Hash', './_Map'], function(Hash, Map) {
* @memberOf MapCache * @memberOf MapCache
*/ */
function mapClear() { 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; return mapClear;

View File

@@ -1,5 +1,8 @@
define(['./_composeArgs', './_composeArgsRight', './_copyArray', './_replaceHolders'], function(composeArgs, composeArgsRight, copyArray, replaceHolders) { define(['./_composeArgs', './_composeArgsRight', './_copyArray', './_replaceHolders'], function(composeArgs, composeArgsRight, copyArray, replaceHolders) {
/** Used as the internal argument placeholder. */
var PLACEHOLDER = '__lodash_placeholder__';
/** Used to compose bitmasks for wrapper metadata. */ /** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1, var BIND_FLAG = 1,
BIND_KEY_FLAG = 2, BIND_KEY_FLAG = 2,
@@ -8,9 +11,6 @@ define(['./_composeArgs', './_composeArgsRight', './_copyArray', './_replaceHold
ARY_FLAG = 128, ARY_FLAG = 128,
REARG_FLAG = 256; REARG_FLAG = 256;
/** Used as the internal argument placeholder. */
var PLACEHOLDER = '__lodash_placeholder__';
/* Built-in method references for those with the same name as other `lodash` methods. */ /* Built-in method references for those with the same name as other `lodash` methods. */
var nativeMin = Math.min; var nativeMin = Math.min;
@@ -36,9 +36,9 @@ define(['./_composeArgs', './_composeArgsRight', './_copyArray', './_replaceHold
isCommon = newBitmask < (BIND_FLAG | BIND_KEY_FLAG | ARY_FLAG); isCommon = newBitmask < (BIND_FLAG | BIND_KEY_FLAG | ARY_FLAG);
var isCombo = var isCombo =
(srcBitmask == ARY_FLAG && (bitmask == CURRY_FLAG)) || ((srcBitmask == ARY_FLAG) && (bitmask == CURRY_FLAG)) ||
(srcBitmask == ARY_FLAG && (bitmask == REARG_FLAG) && (data[7].length <= source[8])) || ((srcBitmask == ARY_FLAG) && (bitmask == REARG_FLAG) && (data[7].length <= source[8])) ||
(srcBitmask == (ARY_FLAG | REARG_FLAG) && (source[7].length <= source[8]) && (bitmask == CURRY_FLAG)); ((srcBitmask == (ARY_FLAG | REARG_FLAG)) && (source[7].length <= source[8]) && (bitmask == CURRY_FLAG));
// Exit early if metadata can't be merged. // Exit early if metadata can't be merged.
if (!(isCommon || isCombo)) { if (!(isCommon || isCombo)) {
@@ -48,7 +48,7 @@ define(['./_composeArgs', './_composeArgsRight', './_copyArray', './_replaceHold
if (srcBitmask & BIND_FLAG) { if (srcBitmask & BIND_FLAG) {
data[2] = source[2]; data[2] = source[2];
// Set when currying a bound function. // Set when currying a bound function.
newBitmask |= (bitmask & BIND_FLAG) ? 0 : CURRY_BOUND_FLAG; newBitmask |= bitmask & BIND_FLAG ? 0 : CURRY_BOUND_FLAG;
} }
// Compose partial arguments. // Compose partial arguments.
var value = source[3]; var value = source[3];

View File

@@ -17,8 +17,7 @@ define(['./_baseMerge', './isObject'], function(baseMerge, isObject) {
*/ */
function mergeDefaults(objValue, srcValue, key, object, source, stack) { function mergeDefaults(objValue, srcValue, key, object, source, stack) {
if (isObject(objValue) && isObject(srcValue)) { if (isObject(objValue) && isObject(srcValue)) {
stack.set(srcValue, objValue); baseMerge(objValue, srcValue, undefined, mergeDefaults, stack.set(srcValue, objValue));
baseMerge(objValue, srcValue, undefined, mergeDefaults, stack);
} }
return objValue; return objValue;
} }

View File

@@ -15,13 +15,14 @@ define([], function() {
function replaceHolders(array, placeholder) { function replaceHolders(array, placeholder) {
var index = -1, var index = -1,
length = array.length, length = array.length,
resIndex = -1, resIndex = 0,
result = []; result = [];
while (++index < length) { while (++index < length) {
if (array[index] === placeholder) { var value = array[index];
if (value === placeholder || value === PLACEHOLDER) {
array[index] = PLACEHOLDER; array[index] = PLACEHOLDER;
result[++resIndex] = index; result[resIndex++] = index;
} }
} }
return result; return result;

View File

@@ -1,5 +1,8 @@
define(['./_checkGlobal'], function(checkGlobal) { 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`. */ /** Used to determine if values are of the language type `Object`. */
var objectTypes = { var objectTypes = {
'function': true, 'function': true,
@@ -7,10 +10,14 @@ define(['./_checkGlobal'], function(checkGlobal) {
}; };
/** Detect free variable `exports`. */ /** 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`. */ /** 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. */ /** Detect free variable `global` from Node.js. */
var freeGlobal = checkGlobal(freeExports && freeModule && typeof global == 'object' && global); 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 * The `this` value is used if it's the global object to avoid Greasemonkey's
* restricted `window` object, otherwise the `window` object is used. * 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; return root;
}); });

View File

@@ -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;
});

View File

@@ -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', './pullAllWith', './pullAt', './remove', './reverse', './slice', './sortedIndex', './sortedIndexBy', './sortedIndexOf', './sortedLastIndex', './sortedLastIndexBy', './sortedLastIndexOf', './sortedUniq', './sortedUniqBy', './tail', './take', './takeRight', './takeRightWhile', './takeWhile', './union', './unionBy', './unionWith', './uniq', './uniqBy', './uniqWith', './unzip', './unzipWith', './without', './xor', './xorBy', './xorWith', './zip', './zipObject', './zipObjectDeep', './zipWith'], 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, pullAllWith, pullAt, remove, reverse, slice, sortedIndex, sortedIndexBy, sortedIndexOf, sortedLastIndex, sortedLastIndexBy, sortedLastIndexOf, sortedUniq, sortedUniqBy, tail, take, takeRight, takeRightWhile, takeWhile, union, unionBy, unionWith, uniq, uniqBy, uniqWith, unzip, unzipWith, without, xor, xorBy, xorWith, zip, zipObject, zipObjectDeep, zipWith) {
return { return {
'chunk': chunk, 'chunk': chunk,
'compact': compact, 'compact': compact,
@@ -15,6 +15,7 @@ define(['./chunk', './compact', './concat', './difference', './differenceBy', '.
'findLastIndex': findLastIndex, 'findLastIndex': findLastIndex,
'flatten': flatten, 'flatten': flatten,
'flattenDeep': flattenDeep, 'flattenDeep': flattenDeep,
'flattenDepth': flattenDepth,
'fromPairs': fromPairs, 'fromPairs': fromPairs,
'head': head, 'head': head,
'indexOf': indexOf, 'indexOf': indexOf,
@@ -28,6 +29,7 @@ define(['./chunk', './compact', './concat', './difference', './differenceBy', '.
'pull': pull, 'pull': pull,
'pullAll': pullAll, 'pullAll': pullAll,
'pullAllBy': pullAllBy, 'pullAllBy': pullAllBy,
'pullAllWith': pullAllWith,
'pullAt': pullAt, 'pullAt': pullAt,
'remove': remove, 'remove': remove,
'reverse': reverse, 'reverse': reverse,

View File

@@ -1,4 +1,13 @@
define(['./_copyObject', './_createAssigner', './keys'], function(copyObject, createAssigner, keys) { define(['./_assignValue', './_copyObject', './_createAssigner', './isArrayLike', './_isPrototype', './keys'], function(assignValue, copyObject, createAssigner, isArrayLike, isPrototype, keys) {
/** Used for built-in method references. */
var objectProto = Object.prototype;
/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;
/** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */
var nonEnumShadows = !({ 'valueOf': 1 }).propertyIsEnumerable('valueOf');
/** /**
* Assigns own enumerable properties of source objects to the destination * Assigns own enumerable properties of source objects to the destination
@@ -31,7 +40,15 @@ define(['./_copyObject', './_createAssigner', './keys'], function(copyObject, cr
* // => { 'a': 1, 'c': 3, 'e': 5 } * // => { 'a': 1, 'c': 3, 'e': 5 }
*/ */
var assign = createAssigner(function(object, source) { var assign = createAssigner(function(object, source) {
copyObject(source, keys(source), object); if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {
copyObject(source, keys(source), object);
return;
}
for (var key in source) {
if (hasOwnProperty.call(source, key)) {
assignValue(object, key, source[key]);
}
}
}); });
return assign; return assign;

View File

@@ -1,4 +1,7 @@
define(['./_copyObject', './_createAssigner', './keysIn'], function(copyObject, createAssigner, keysIn) { define(['./_assignValue', './_copyObject', './_createAssigner', './isArrayLike', './_isPrototype', './keysIn'], function(assignValue, copyObject, createAssigner, isArrayLike, isPrototype, keysIn) {
/** Detect if properties shadowing those on `Object.prototype` are non-enumerable. */
var nonEnumShadows = !({ 'valueOf': 1 }).propertyIsEnumerable('valueOf');
/** /**
* This method is like `_.assign` except that it iterates over own and * This method is like `_.assign` except that it iterates over own and
@@ -30,7 +33,13 @@ define(['./_copyObject', './_createAssigner', './keysIn'], function(copyObject,
* // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5 } * // => { 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5 }
*/ */
var assignIn = createAssigner(function(object, source) { var assignIn = createAssigner(function(object, source) {
copyObject(source, keysIn(source), object); if (nonEnumShadows || isPrototype(source) || isArrayLike(source)) {
copyObject(source, keysIn(source), object);
return;
}
for (var key in source) {
assignValue(object, key, source[key]);
}
}); });
return assignIn; return assignIn;

2
at.js
View File

@@ -21,7 +21,7 @@ define(['./_baseAt', './_baseFlatten', './rest'], function(baseAt, baseFlatten,
* // => ['a', 'c'] * // => ['a', 'c']
*/ */
var at = rest(function(object, paths) { var at = rest(function(object, paths) {
return baseAt(object, baseFlatten(paths)); return baseAt(object, baseFlatten(paths, 1));
}); });
return at; return at;

View File

@@ -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. */ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined; var undefined;
@@ -27,7 +27,7 @@ define(['./_apply', './isObject', './rest'], function(apply, isObject, rest) {
try { try {
return apply(func, undefined, args); return apply(func, undefined, args);
} catch (e) { } catch (e) {
return isObject(e) ? e : new Error(e); return isError(e) ? e : new Error(e);
} }
}); });

View File

@@ -1,4 +1,4 @@
define(['./_createWrapper', './_replaceHolders', './rest'], function(createWrapper, replaceHolders, rest) { define(['./_createWrapper', './_getPlaceholder', './_replaceHolders', './rest'], function(createWrapper, getPlaceholder, replaceHolders, rest) {
/** Used to compose bitmasks for wrapper metadata. */ /** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1, var BIND_FLAG = 1,
@@ -42,9 +42,7 @@ define(['./_createWrapper', './_replaceHolders', './rest'], function(createWrapp
var bind = rest(function(func, thisArg, partials) { var bind = rest(function(func, thisArg, partials) {
var bitmask = BIND_FLAG; var bitmask = BIND_FLAG;
if (partials.length) { if (partials.length) {
var placeholder = bind.placeholder, var holders = replaceHolders(partials, getPlaceholder(bind));
holders = replaceHolders(partials, placeholder);
bitmask |= PARTIAL_FLAG; bitmask |= PARTIAL_FLAG;
} }
return createWrapper(func, bitmask, thisArg, partials, holders); return createWrapper(func, bitmask, thisArg, partials, holders);

View File

@@ -27,7 +27,7 @@ define(['./_arrayEach', './_baseFlatten', './bind', './rest'], function(arrayEac
* // => logs 'clicked docs' when clicked * // => logs 'clicked docs' when clicked
*/ */
var bindAll = rest(function(object, methodNames) { var bindAll = rest(function(object, methodNames) {
arrayEach(baseFlatten(methodNames), function(key) { arrayEach(baseFlatten(methodNames, 1), function(key) {
object[key] = bind(object[key], object); object[key] = bind(object[key], object);
}); });
return object; return object;

View File

@@ -1,4 +1,4 @@
define(['./_createWrapper', './_replaceHolders', './rest'], function(createWrapper, replaceHolders, rest) { define(['./_createWrapper', './_getPlaceholder', './_replaceHolders', './rest'], function(createWrapper, getPlaceholder, replaceHolders, rest) {
/** Used to compose bitmasks for wrapper metadata. */ /** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1, var BIND_FLAG = 1,
@@ -52,9 +52,7 @@ define(['./_createWrapper', './_replaceHolders', './rest'], function(createWrapp
var bindKey = rest(function(object, key, partials) { var bindKey = rest(function(object, key, partials) {
var bitmask = BIND_FLAG | BIND_KEY_FLAG; var bitmask = BIND_FLAG | BIND_KEY_FLAG;
if (partials.length) { if (partials.length) {
var placeholder = bindKey.placeholder, var holders = replaceHolders(partials, getPlaceholder(bindKey));
holders = replaceHolders(partials, placeholder);
bitmask |= PARTIAL_FLAG; bitmask |= PARTIAL_FLAG;
} }
return createWrapper(key, bitmask, object, partials, holders); return createWrapper(key, bitmask, object, partials, holders);

44
castArray.js Normal file
View File

@@ -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;
});

View File

@@ -31,11 +31,11 @@ define(['./_baseSlice', './toInteger'], function(baseSlice, toInteger) {
return []; return [];
} }
var index = 0, var index = 0,
resIndex = -1, resIndex = 0,
result = Array(nativeCeil(length / size)); result = Array(nativeCeil(length / size));
while (index < length) { while (index < length) {
result[++resIndex] = baseSlice(array, index, (index += size)); result[resIndex++] = baseSlice(array, index, (index += size));
} }
return result; return result;
} }

View File

@@ -17,13 +17,13 @@ define([], function() {
function compact(array) { function compact(array) {
var index = -1, var index = -1,
length = array ? array.length : 0, length = array ? array.length : 0,
resIndex = -1, resIndex = 0,
result = []; result = [];
while (++index < length) { while (++index < length) {
var value = array[index]; var value = array[index];
if (value) { if (value) {
result[++resIndex] = value; result[resIndex++] = value;
} }
} }
return result; return result;

View File

@@ -25,7 +25,7 @@ define(['./_arrayConcat', './_baseFlatten', './isArray', './rest'], function(arr
if (!isArray(array)) { if (!isArray(array)) {
array = array == null ? [] : [Object(array)]; array = array == null ? [] : [Object(array)];
} }
values = baseFlatten(values); values = baseFlatten(values, 1);
return arrayConcat(array, values); return arrayConcat(array, values);
}); });

View File

@@ -139,8 +139,10 @@ define(['./isObject', './now', './toNumber'], function(isObject, now, toNumber)
if (!lastCalled && !maxTimeoutId && !leading) { if (!lastCalled && !maxTimeoutId && !leading) {
lastCalled = stamp; lastCalled = stamp;
} }
var remaining = maxWait - (stamp - lastCalled), var remaining = maxWait - (stamp - lastCalled);
isCalled = remaining <= 0 || remaining > maxWait;
var isCalled = (remaining <= 0 || remaining > maxWait) &&
(leading || maxTimeoutId);
if (isCalled) { if (isCalled) {
if (maxTimeoutId) { if (maxTimeoutId) {

View File

@@ -3,7 +3,8 @@ define(['./_baseDifference', './_baseFlatten', './isArrayLikeObject', './rest'],
/** /**
* Creates an array of unique `array` values not included in the other * Creates an array of unique `array` values not included in the other
* given arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) * given arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
* for equality comparisons. * for equality comparisons. The order of result values is determined by the
* order they occur in the first array.
* *
* @static * @static
* @memberOf _ * @memberOf _
@@ -18,7 +19,7 @@ define(['./_baseDifference', './_baseFlatten', './isArrayLikeObject', './rest'],
*/ */
var difference = rest(function(array, values) { var difference = rest(function(array, values) {
return isArrayLikeObject(array) return isArrayLikeObject(array)
? baseDifference(array, baseFlatten(values, false, true)) ? baseDifference(array, baseFlatten(values, 1, true))
: []; : [];
}); });

View File

@@ -6,7 +6,8 @@ define(['./_baseDifference', './_baseFlatten', './_baseIteratee', './isArrayLike
/** /**
* This method is like `_.difference` except that it accepts `iteratee` which * This method is like `_.difference` except that it accepts `iteratee` which
* is invoked for each element of `array` and `values` to generate the criterion * is invoked for each element of `array` and `values` to generate the criterion
* by which uniqueness is computed. The iteratee is invoked with one argument: (value). * by which they're compared. Result values are chosen from the first array.
* The iteratee is invoked with one argument: (value).
* *
* @static * @static
* @memberOf _ * @memberOf _
@@ -30,7 +31,7 @@ define(['./_baseDifference', './_baseFlatten', './_baseIteratee', './isArrayLike
iteratee = undefined; iteratee = undefined;
} }
return isArrayLikeObject(array) return isArrayLikeObject(array)
? baseDifference(array, baseFlatten(values, false, true), baseIteratee(iteratee)) ? baseDifference(array, baseFlatten(values, 1, true), baseIteratee(iteratee))
: []; : [];
}); });

View File

@@ -5,8 +5,9 @@ define(['./_baseDifference', './_baseFlatten', './isArrayLikeObject', './last',
/** /**
* This method is like `_.difference` except that it accepts `comparator` * This method is like `_.difference` except that it accepts `comparator`
* which is invoked to compare elements of `array` to `values`. The comparator * which is invoked to compare elements of `array` to `values`. Result values
* is invoked with two arguments: (arrVal, othVal). * are chosen from the first array. The comparator is invoked with two arguments:
* (arrVal, othVal).
* *
* @static * @static
* @memberOf _ * @memberOf _
@@ -28,7 +29,7 @@ define(['./_baseDifference', './_baseFlatten', './isArrayLikeObject', './last',
comparator = undefined; comparator = undefined;
} }
return isArrayLikeObject(array) return isArrayLikeObject(array)
? baseDifference(array, baseFlatten(values, false, true), undefined, comparator) ? baseDifference(array, baseFlatten(values, 1, true), undefined, comparator)
: []; : [];
}); });

View File

@@ -21,7 +21,7 @@ define(['./_baseFlatten', './map'], function(baseFlatten, map) {
* // => [1, 1, 2, 2] * // => [1, 1, 2, 2]
*/ */
function flatMap(collection, iteratee) { function flatMap(collection, iteratee) {
return baseFlatten(map(collection, iteratee)); return baseFlatten(map(collection, iteratee), 1);
} }
return flatMap; return flatMap;

View File

@@ -1,7 +1,7 @@
define(['./_baseFlatten'], function(baseFlatten) { define(['./_baseFlatten'], function(baseFlatten) {
/** /**
* Flattens `array` a single level. * Flattens `array` a single level deep.
* *
* @static * @static
* @memberOf _ * @memberOf _
@@ -10,12 +10,12 @@ define(['./_baseFlatten'], function(baseFlatten) {
* @returns {Array} Returns the new flattened array. * @returns {Array} Returns the new flattened array.
* @example * @example
* *
* _.flatten([1, [2, 3, [4]]]); * _.flatten([1, [2, [3, [4]], 5]]);
* // => [1, 2, 3, [4]] * // => [1, 2, [3, [4]], 5]
*/ */
function flatten(array) { function flatten(array) {
var length = array ? array.length : 0; var length = array ? array.length : 0;
return length ? baseFlatten(array) : []; return length ? baseFlatten(array, 1) : [];
} }
return flatten; return flatten;

View File

@@ -1,21 +1,24 @@
define(['./_baseFlatten'], function(baseFlatten) { 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 * @static
* @memberOf _ * @memberOf _
* @category Array * @category Array
* @param {Array} array The array to recursively flatten. * @param {Array} array The array to flatten.
* @returns {Array} Returns the new flattened array. * @returns {Array} Returns the new flattened array.
* @example * @example
* *
* _.flattenDeep([1, [2, 3, [4]]]); * _.flattenDeep([1, [2, [3, [4]], 5]]);
* // => [1, 2, 3, 4] * // => [1, 2, 3, 4, 5]
*/ */
function flattenDeep(array) { function flattenDeep(array) {
var length = array ? array.length : 0; var length = array ? array.length : 0;
return length ? baseFlatten(array, true) : []; return length ? baseFlatten(array, INFINITY) : [];
} }
return flattenDeep; return flattenDeep;

35
flattenDepth.js Normal file
View File

@@ -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;
});

View File

@@ -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. * 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) { function forEach(collection, iteratee) {
return (typeof iteratee == 'function' && isArray(collection)) return (typeof iteratee == 'function' && isArray(collection))
? arrayEach(collection, iteratee) ? arrayEach(collection, iteratee)
: baseEach(collection, toFunction(iteratee)); : baseEach(collection, baseCastFunction(iteratee));
} }
return forEach; return forEach;

View File

@@ -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 * 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) { function forEachRight(collection, iteratee) {
return (typeof iteratee == 'function' && isArray(collection)) return (typeof iteratee == 'function' && isArray(collection))
? arrayEachRight(collection, iteratee) ? arrayEachRight(collection, iteratee)
: baseEachRight(collection, toFunction(iteratee)); : baseEachRight(collection, baseCastFunction(iteratee));
} }
return forEachRight; return forEachRight;

View File

@@ -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 * 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) * // => logs 'a', 'b', then 'c' (iteration order is not guaranteed)
*/ */
function forIn(object, iteratee) { function forIn(object, iteratee) {
return object == null ? object : baseFor(object, toFunction(iteratee), keysIn); return object == null
? object
: baseFor(object, baseCastFunction(iteratee), keysIn);
} }
return forIn; return forIn;

View File

@@ -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 * 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' * // => logs 'c', 'b', then 'a' assuming `_.forIn` logs 'a', 'b', then 'c'
*/ */
function forInRight(object, iteratee) { function forInRight(object, iteratee) {
return object == null ? object : baseForRight(object, toFunction(iteratee), keysIn); return object == null
? object
: baseForRight(object, baseCastFunction(iteratee), keysIn);
} }
return forInRight; return forInRight;

View File

@@ -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` * 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) * // => logs 'a' then 'b' (iteration order is not guaranteed)
*/ */
function forOwn(object, iteratee) { function forOwn(object, iteratee) {
return object && baseForOwn(object, toFunction(iteratee)); return object && baseForOwn(object, baseCastFunction(iteratee));
} }
return forOwn; return forOwn;

View File

@@ -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 * 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' * // => logs 'b' then 'a' assuming `_.forOwn` logs 'a' then 'b'
*/ */
function forOwnRight(object, iteratee) { function forOwnRight(object, iteratee) {
return object && baseForOwnRight(object, toFunction(iteratee)); return object && baseForOwnRight(object, baseCastFunction(iteratee));
} }
return forOwnRight; return forOwnRight;

View File

@@ -1,22 +1,23 @@
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 * Creates an array of unique values that are included in all given arrays
* using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) * using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
* for equality comparisons. * for equality comparisons. The order of result values is determined by the
* order they occur in the first array.
* *
* @static * @static
* @memberOf _ * @memberOf _
* @category Array * @category Array
* @param {...Array} [arrays] The arrays to inspect. * @param {...Array} [arrays] The arrays to inspect.
* @returns {Array} Returns the new array of shared values. * @returns {Array} Returns the new array of intersecting values.
* @example * @example
* *
* _.intersection([2, 1], [4, 2], [1, 2]); * _.intersection([2, 1], [4, 2], [1, 2]);
* // => [2] * // => [2]
*/ */
var intersection = rest(function(arrays) { var intersection = rest(function(arrays) {
var mapped = arrayMap(arrays, toArrayLikeObject); var mapped = arrayMap(arrays, baseCastArrayLikeObject);
return (mapped.length && mapped[0] === arrays[0]) return (mapped.length && mapped[0] === arrays[0])
? baseIntersection(mapped) ? baseIntersection(mapped)
: []; : [];

View File

@@ -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. */ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined; var undefined;
@@ -6,14 +6,15 @@ define(['./_arrayMap', './_baseIntersection', './_baseIteratee', './last', './re
/** /**
* This method is like `_.intersection` except that it accepts `iteratee` * This method is like `_.intersection` except that it accepts `iteratee`
* which is invoked for each element of each `arrays` to generate the criterion * which is invoked for each element of each `arrays` to generate the criterion
* by which uniqueness is computed. The iteratee is invoked with one argument: (value). * by which they're compared. Result values are chosen from the first array.
* The iteratee is invoked with one argument: (value).
* *
* @static * @static
* @memberOf _ * @memberOf _
* @category Array * @category Array
* @param {...Array} [arrays] The arrays to inspect. * @param {...Array} [arrays] The arrays to inspect.
* @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element. * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element.
* @returns {Array} Returns the new array of shared values. * @returns {Array} Returns the new array of intersecting values.
* @example * @example
* *
* _.intersectionBy([2.1, 1.2], [4.3, 2.4], Math.floor); * _.intersectionBy([2.1, 1.2], [4.3, 2.4], Math.floor);
@@ -25,7 +26,7 @@ define(['./_arrayMap', './_baseIntersection', './_baseIteratee', './last', './re
*/ */
var intersectionBy = rest(function(arrays) { var intersectionBy = rest(function(arrays) {
var iteratee = last(arrays), var iteratee = last(arrays),
mapped = arrayMap(arrays, toArrayLikeObject); mapped = arrayMap(arrays, baseCastArrayLikeObject);
if (iteratee === last(mapped)) { if (iteratee === last(mapped)) {
iteratee = undefined; iteratee = undefined;

View File

@@ -1,19 +1,20 @@
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. */ /** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined; var undefined;
/** /**
* This method is like `_.intersection` except that it accepts `comparator` * This method is like `_.intersection` except that it accepts `comparator`
* which is invoked to compare elements of `arrays`. The comparator is invoked * which is invoked to compare elements of `arrays`. Result values are chosen
* with two arguments: (arrVal, othVal). * from the first array. The comparator is invoked with two arguments:
* (arrVal, othVal).
* *
* @static * @static
* @memberOf _ * @memberOf _
* @category Array * @category Array
* @param {...Array} [arrays] The arrays to inspect. * @param {...Array} [arrays] The arrays to inspect.
* @param {Function} [comparator] The comparator invoked per element. * @param {Function} [comparator] The comparator invoked per element.
* @returns {Array} Returns the new array of shared values. * @returns {Array} Returns the new array of intersecting values.
* @example * @example
* *
* var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]; * var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
@@ -24,7 +25,7 @@ define(['./_arrayMap', './_baseIntersection', './last', './rest', './_toArrayLik
*/ */
var intersectionWith = rest(function(arrays) { var intersectionWith = rest(function(arrays) {
var comparator = last(arrays), var comparator = last(arrays),
mapped = arrayMap(arrays, toArrayLikeObject); mapped = arrayMap(arrays, baseCastArrayLikeObject);
if (comparator === last(mapped)) { if (comparator === last(mapped)) {
comparator = undefined; comparator = undefined;

View File

@@ -5,7 +5,7 @@ define([], function() {
* *
* @static * @static
* @memberOf _ * @memberOf _
* @type Function * @type {Function}
* @category Lang * @category Lang
* @param {*} value The value to check. * @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.

View File

@@ -16,7 +16,6 @@ define(['./isObjectLike'], function(isObjectLike) {
* *
* @static * @static
* @memberOf _ * @memberOf _
* @type Function
* @category Lang * @category Lang
* @param {*} value The value to check. * @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is correctly classified, else `false`. * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.

Some files were not shown because too many files have changed in this diff Show More