Compare commits

...

4 Commits

Author SHA1 Message Date
John-David Dalton
32393ae520 Bump to v3.9.3. 2015-12-16 17:51:44 -08:00
John-David Dalton
d2754e0b9b Bump to v3.9.2. 2015-12-16 17:51:09 -08:00
John-David Dalton
81e41ca0c8 Bump to v3.9.0. 2015-12-16 17:50:42 -08:00
John-David Dalton
26837e7fe2 Bump to v3.8.0. 2015-12-16 17:50:05 -08:00
138 changed files with 1614 additions and 1441 deletions

View File

@@ -1,4 +1,4 @@
# lodash v3.7.0 # lodash v3.9.3
The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash](https://lodash.com/) exported as [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules. The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash](https://lodash.com/) exported as [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) modules.
@@ -13,8 +13,8 @@ $ lodash modern exports=amd -d -o ./main.js
Using bower or volo: Using bower or volo:
```bash ```bash
$ bower i lodash#3.7.0-amd $ bower i lodash#3.9.3-amd
$ volo add lodash/3.7.0-amd $ volo add lodash/3.9.3-amd
``` ```
Defining a build as `'lodash'`. Defining a build as `'lodash'`.

View File

@@ -1,4 +1,4 @@
define(['./array/chunk', './array/compact', './array/difference', './array/drop', './array/dropRight', './array/dropRightWhile', './array/dropWhile', './array/fill', './array/findIndex', './array/findLastIndex', './array/first', './array/flatten', './array/flattenDeep', './array/head', './array/indexOf', './array/initial', './array/intersection', './array/last', './array/lastIndexOf', './array/object', './array/pull', './array/pullAt', './array/remove', './array/rest', './array/slice', './array/sortedIndex', './array/sortedLastIndex', './array/tail', './array/take', './array/takeRight', './array/takeRightWhile', './array/takeWhile', './array/union', './array/uniq', './array/unique', './array/unzip', './array/without', './array/xor', './array/zip', './array/zipObject'], function(chunk, compact, difference, drop, dropRight, dropRightWhile, dropWhile, fill, findIndex, findLastIndex, first, flatten, flattenDeep, head, indexOf, initial, intersection, last, lastIndexOf, object, pull, pullAt, remove, rest, slice, sortedIndex, sortedLastIndex, tail, take, takeRight, takeRightWhile, takeWhile, union, uniq, unique, unzip, without, xor, zip, zipObject) { define(['./array/chunk', './array/compact', './array/difference', './array/drop', './array/dropRight', './array/dropRightWhile', './array/dropWhile', './array/fill', './array/findIndex', './array/findLastIndex', './array/first', './array/flatten', './array/flattenDeep', './array/head', './array/indexOf', './array/initial', './array/intersection', './array/last', './array/lastIndexOf', './array/object', './array/pull', './array/pullAt', './array/remove', './array/rest', './array/slice', './array/sortedIndex', './array/sortedLastIndex', './array/tail', './array/take', './array/takeRight', './array/takeRightWhile', './array/takeWhile', './array/union', './array/uniq', './array/unique', './array/unzip', './array/unzipWith', './array/without', './array/xor', './array/zip', './array/zipObject', './array/zipWith'], function(chunk, compact, difference, drop, dropRight, dropRightWhile, dropWhile, fill, findIndex, findLastIndex, first, flatten, flattenDeep, head, indexOf, initial, intersection, last, lastIndexOf, object, pull, pullAt, remove, rest, slice, sortedIndex, sortedLastIndex, tail, take, takeRight, takeRightWhile, takeWhile, union, uniq, unique, unzip, unzipWith, without, xor, zip, zipObject, zipWith) {
return { return {
'chunk': chunk, 'chunk': chunk,
'compact': compact, 'compact': compact,
@@ -36,9 +36,11 @@ define(['./array/chunk', './array/compact', './array/difference', './array/drop'
'uniq': uniq, 'uniq': uniq,
'unique': unique, 'unique': unique,
'unzip': unzip, 'unzip': unzip,
'unzipWith': unzipWith,
'without': without, 'without': without,
'xor': xor, 'xor': xor,
'zip': zip, 'zip': zip,
'zipObject': zipObject 'zipObject': zipObject,
'zipWith': zipWith
}; };
}); });

View File

@@ -1,12 +1,9 @@
define(['../internal/baseDifference', '../internal/baseFlatten', '../lang/isArguments', '../lang/isArray', '../function/restParam'], function(baseDifference, baseFlatten, isArguments, isArray, restParam) { define(['../internal/baseDifference', '../internal/baseFlatten', '../internal/isArrayLike', '../function/restParam'], function(baseDifference, baseFlatten, isArrayLike, restParam) {
/** /**
* Creates an array excluding all values of the provided arrays using * Creates an array of unique `array` values not included in the other
* `SameValueZero` for equality comparisons. * provided arrays using [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* * for equality comparisons.
* **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* comparisons are like strict equality comparisons, e.g. `===`, except that
* `NaN` matches `NaN`.
* *
* @static * @static
* @memberOf _ * @memberOf _
@@ -20,7 +17,7 @@ define(['../internal/baseDifference', '../internal/baseFlatten', '../lang/isArgu
* // => [1, 3] * // => [1, 3]
*/ */
var difference = restParam(function(array, values) { var difference = restParam(function(array, values) {
return (isArray(array) || isArguments(array)) return isArrayLike(array)
? baseDifference(array, baseFlatten(values, false, true)) ? baseDifference(array, baseFlatten(values, false, true))
: []; : [];
}); });

View File

@@ -5,13 +5,10 @@ define(['../internal/baseIndexOf', '../internal/binaryIndex'], function(baseInde
/** /**
* Gets the index at which the first occurrence of `value` is found in `array` * Gets the index at which the first occurrence of `value` is found in `array`
* using `SameValueZero` for equality comparisons. If `fromIndex` is negative, * using [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* it is used as the offset from the end of `array`. If `array` is sorted * for equality comparisons. If `fromIndex` is negative, it is used as the offset
* providing `true` for `fromIndex` performs a faster binary search. * from the end of `array`. If `array` is sorted providing `true` for `fromIndex`
* * performs a faster binary search.
* **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* comparisons are like strict equality comparisons, e.g. `===`, except that
* `NaN` matches `NaN`.
* *
* @static * @static
* @memberOf _ * @memberOf _

View File

@@ -1,13 +1,10 @@
define(['../internal/baseIndexOf', '../internal/cacheIndexOf', '../internal/createCache', '../lang/isArguments', '../lang/isArray'], function(baseIndexOf, cacheIndexOf, createCache, isArguments, isArray) { define(['../internal/baseIndexOf', '../internal/cacheIndexOf', '../internal/createCache', '../internal/isArrayLike', '../function/restParam'], function(baseIndexOf, cacheIndexOf, createCache, isArrayLike, restParam) {
/** /**
* Creates an array of unique values in all provided arrays using `SameValueZero` * Creates an array of unique values that are included in all of the provided
* arrays using [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* for equality comparisons. * for equality comparisons.
* *
* **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* comparisons are like strict equality comparisons, e.g. `===`, except that
* `NaN` matches `NaN`.
*
* @static * @static
* @memberOf _ * @memberOf _
* @category Array * @category Array
@@ -17,27 +14,19 @@ define(['../internal/baseIndexOf', '../internal/cacheIndexOf', '../internal/crea
* _.intersection([1, 2], [4, 2], [2, 1]); * _.intersection([1, 2], [4, 2], [2, 1]);
* // => [2] * // => [2]
*/ */
function intersection() { var intersection = restParam(function(arrays) {
var args = [], var othLength = arrays.length,
argsIndex = -1, othIndex = othLength,
argsLength = arguments.length, caches = Array(length),
caches = [],
indexOf = baseIndexOf, indexOf = baseIndexOf,
isCommon = true, isCommon = true,
result = []; result = [];
while (++argsIndex < argsLength) { while (othIndex--) {
var value = arguments[argsIndex]; var value = arrays[othIndex] = isArrayLike(value = arrays[othIndex]) ? value : [];
if (isArray(value) || isArguments(value)) { caches[othIndex] = (isCommon && value.length >= 120) ? createCache(othIndex && value) : null;
args.push(value);
caches.push((isCommon && value.length >= 120) ? createCache(argsIndex && value) : null);
}
} }
argsLength = args.length; var array = arrays[0],
if (argsLength < 2) {
return result;
}
var array = args[0],
index = -1, index = -1,
length = array ? array.length : 0, length = array ? array.length : 0,
seen = caches[0]; seen = caches[0];
@@ -46,10 +35,10 @@ define(['../internal/baseIndexOf', '../internal/cacheIndexOf', '../internal/crea
while (++index < length) { while (++index < length) {
value = array[index]; value = array[index];
if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value, 0)) < 0) { if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value, 0)) < 0) {
argsIndex = argsLength; var othIndex = othLength;
while (--argsIndex) { while (--othIndex) {
var cache = caches[argsIndex]; var cache = caches[othIndex];
if ((cache ? cacheIndexOf(cache, value) : indexOf(args[argsIndex], value, 0)) < 0) { if ((cache ? cacheIndexOf(cache, value) : indexOf(arrays[othIndex], value, 0)) < 0) {
continue outer; continue outer;
} }
} }
@@ -60,7 +49,7 @@ define(['../internal/baseIndexOf', '../internal/cacheIndexOf', '../internal/crea
} }
} }
return result; return result;
} });
return intersection; return intersection;
}); });

View File

@@ -7,14 +7,11 @@ define(['../internal/baseIndexOf'], function(baseIndexOf) {
var splice = arrayProto.splice; var splice = arrayProto.splice;
/** /**
* Removes all provided values from `array` using `SameValueZero` for equality * Removes all provided values from `array` using
* comparisons. * [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* for equality comparisons.
* *
* **Notes:** * **Note:** Unlike `_.without`, this method mutates `array`.
* - Unlike `_.without`, this method mutates `array`
* - [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* comparisons are like strict equality comparisons, e.g. `===`, except
* that `NaN` matches `NaN`
* *
* @static * @static
* @memberOf _ * @memberOf _

View File

@@ -26,7 +26,6 @@ define(['../internal/baseAt', '../internal/baseCompareAscending', '../internal/b
* // => [10, 20] * // => [10, 20]
*/ */
var pullAt = restParam(function(array, indexes) { var pullAt = restParam(function(array, indexes) {
array || (array = []);
indexes = baseFlatten(indexes); indexes = baseFlatten(indexes);
var result = baseAt(array, indexes); var result = baseAt(array, indexes);

View File

@@ -1,12 +1,9 @@
define(['../internal/baseFlatten', '../internal/baseUniq', '../function/restParam'], function(baseFlatten, baseUniq, restParam) { define(['../internal/baseFlatten', '../internal/baseUniq', '../function/restParam'], function(baseFlatten, baseUniq, restParam) {
/** /**
* Creates an array of unique values, in order, of the provided arrays using * Creates an array of unique values, in order, from all of the provided arrays
* `SameValueZero` for equality comparisons. * using [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* * for equality comparisons.
* **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* comparisons are like strict equality comparisons, e.g. `===`, except that
* `NaN` matches `NaN`.
* *
* @static * @static
* @memberOf _ * @memberOf _

View File

@@ -1,8 +1,9 @@
define(['../internal/baseCallback', '../internal/baseUniq', '../internal/isIterateeCall', '../internal/sortedUniq'], function(baseCallback, baseUniq, isIterateeCall, sortedUniq) { define(['../internal/baseCallback', '../internal/baseUniq', '../internal/isIterateeCall', '../internal/sortedUniq'], function(baseCallback, baseUniq, isIterateeCall, sortedUniq) {
/** /**
* Creates a duplicate-free version of an array, using `SameValueZero` for * Creates a duplicate-free version of an array, using
* equality comparisons, in which only the first occurence of each element * [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* for equality comparisons, in which only the first occurence of each element
* is kept. Providing `true` for `isSorted` performs a faster search algorithm * is kept. Providing `true` for `isSorted` performs a faster search algorithm
* for sorted arrays. If an iteratee function is provided it is invoked for * for sorted arrays. If an iteratee function is provided it is invoked for
* each element in the array to generate the criterion by which uniqueness * each element in the array to generate the criterion by which uniqueness
@@ -20,10 +21,6 @@ define(['../internal/baseCallback', '../internal/baseUniq', '../internal/isItera
* callback returns `true` for elements that have the properties of the given * callback returns `true` for elements that have the properties of the given
* object, else `false`. * object, else `false`.
* *
* **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* comparisons are like strict equality comparisons, e.g. `===`, except that
* `NaN` matches `NaN`.
*
* @static * @static
* @memberOf _ * @memberOf _
* @alias unique * @alias unique

View File

@@ -1,8 +1,11 @@
define(['../internal/arrayMap', '../internal/arrayMax', '../internal/baseProperty', '../internal/getLength'], function(arrayMap, arrayMax, baseProperty, getLength) { define(['../internal/arrayFilter', '../internal/arrayMap', '../internal/baseProperty', '../internal/isArrayLike'], function(arrayFilter, arrayMap, baseProperty, isArrayLike) {
/* Native method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max;
/** /**
* This method is like `_.zip` except that it accepts an array of grouped * This method is like `_.zip` except that it accepts an array of grouped
* elements and creates an array regrouping the elements to their pre-`_.zip` * elements and creates an array regrouping the elements to their pre-zip
* configuration. * configuration.
* *
* @static * @static
@@ -19,10 +22,19 @@ define(['../internal/arrayMap', '../internal/arrayMax', '../internal/basePropert
* // => [['fred', 'barney'], [30, 40], [true, false]] * // => [['fred', 'barney'], [30, 40], [true, false]]
*/ */
function unzip(array) { function unzip(array) {
if (!(array && array.length)) {
return [];
}
var index = -1, var index = -1,
length = (array && array.length && arrayMax(arrayMap(array, getLength))) >>> 0, length = 0;
result = Array(length);
array = arrayFilter(array, function(group) {
if (isArrayLike(group)) {
length = nativeMax(group.length, length);
return true;
}
});
var result = Array(length);
while (++index < length) { while (++index < length) {
result[index] = arrayMap(array, baseProperty(index)); result[index] = arrayMap(array, baseProperty(index));
} }

42
array/unzipWith.js Normal file
View File

@@ -0,0 +1,42 @@
define(['../internal/arrayMap', '../internal/arrayReduce', '../internal/bindCallback', './unzip'], function(arrayMap, arrayReduce, bindCallback, unzip) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/**
* This method is like `_.unzip` except that it accepts an iteratee to specify
* how regrouped values should be combined. The `iteratee` is bound to `thisArg`
* and invoked with four arguments: (accumulator, value, index, group).
*
* @static
* @memberOf _
* @category Array
* @param {Array} array The array of grouped elements to process.
* @param {Function} [iteratee] The function to combine regrouped values.
* @param {*} [thisArg] The `this` binding of `iteratee`.
* @returns {Array} Returns the new array of regrouped elements.
* @example
*
* var zipped = _.zip([1, 2], [10, 20], [100, 200]);
* // => [[1, 10, 100], [2, 20, 200]]
*
* _.unzipWith(zipped, _.add);
* // => [3, 30, 300]
*/
function unzipWith(array, iteratee, thisArg) {
var length = array ? array.length : 0;
if (!length) {
return [];
}
var result = unzip(array);
if (iteratee == null) {
return result;
}
iteratee = bindCallback(iteratee, thisArg, 4);
return arrayMap(result, function(group) {
return arrayReduce(group, iteratee, undefined, true);
});
}
return unzipWith;
});

View File

@@ -1,12 +1,9 @@
define(['../internal/baseDifference', '../lang/isArguments', '../lang/isArray', '../function/restParam'], function(baseDifference, isArguments, isArray, restParam) { define(['../internal/baseDifference', '../internal/isArrayLike', '../function/restParam'], function(baseDifference, isArrayLike, restParam) {
/** /**
* Creates an array excluding all provided values using `SameValueZero` for * Creates an array excluding all provided values using
* equality comparisons. * [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* * for equality comparisons.
* **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* comparisons are like strict equality comparisons, e.g. `===`, except that
* `NaN` matches `NaN`.
* *
* @static * @static
* @memberOf _ * @memberOf _
@@ -20,7 +17,7 @@ define(['../internal/baseDifference', '../lang/isArguments', '../lang/isArray',
* // => [3] * // => [3]
*/ */
var without = restParam(function(array, values) { var without = restParam(function(array, values) {
return (isArray(array) || isArguments(array)) return isArrayLike(array)
? baseDifference(array, values) ? baseDifference(array, values)
: []; : [];
}); });

View File

@@ -1,7 +1,7 @@
define(['../internal/baseDifference', '../internal/baseUniq', '../lang/isArguments', '../lang/isArray'], function(baseDifference, baseUniq, isArguments, isArray) { define(['../internal/baseDifference', '../internal/baseUniq', '../internal/isArrayLike'], function(baseDifference, baseUniq, isArrayLike) {
/** /**
* Creates an array that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference) * Creates an array of unique values that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
* of the provided arrays. * of the provided arrays.
* *
* @static * @static
@@ -20,7 +20,7 @@ define(['../internal/baseDifference', '../internal/baseUniq', '../lang/isArgumen
while (++index < length) { while (++index < length) {
var array = arguments[index]; var array = arguments[index];
if (isArray(array) || isArguments(array)) { if (isArrayLike(array)) {
var result = result var result = result
? baseDifference(result, array).concat(baseDifference(array, result)) ? baseDifference(result, array).concat(baseDifference(array, result))
: array; : array;

39
array/zipWith.js Normal file
View File

@@ -0,0 +1,39 @@
define(['../function/restParam', './unzipWith'], function(restParam, unzipWith) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/**
* This method is like `_.zip` except that it accepts an iteratee to specify
* how grouped values should be combined. The `iteratee` is bound to `thisArg`
* and invoked with four arguments: (accumulator, value, index, group).
*
* @static
* @memberOf _
* @category Array
* @param {...Array} [arrays] The arrays to process.
* @param {Function} [iteratee] The function to combine grouped values.
* @param {*} [thisArg] The `this` binding of `iteratee`.
* @returns {Array} Returns the new array of grouped elements.
* @example
*
* _.zipWith([1, 2], [10, 20], [100, 200], _.add);
* // => [111, 222]
*/
var zipWith = restParam(function(arrays) {
var length = arrays.length,
iteratee = length > 2 ? arrays[length - 2] : undefined,
thisArg = length > 1 ? arrays[length - 1] : undefined;
if (length > 2 && typeof iteratee == 'function') {
length -= 2;
} else {
iteratee = (length > 1 && typeof thisArg == 'function') ? (--length, thisArg) : undefined;
thisArg = undefined;
}
arrays.length = length;
return unzipWith(arrays, iteratee, thisArg);
});
return zipWith;
});

View File

@@ -45,30 +45,31 @@ define(['../internal/LazyWrapper', '../internal/LodashWrapper', '../internal/bas
* `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`, `forEach`, * `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`, `forEach`,
* `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `functions`, * `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `functions`,
* `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`, * `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`,
* `keysIn`, `map`, `mapValues`, `matches`, `matchesProperty`, `memoize`, * `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`,
* `merge`, `mixin`, `negate`, `omit`, `once`, `pairs`, `partial`, `partialRight`, * `memoize`, `merge`, `method`, `methodOf`, `mixin`, `negate`, `omit`, `once`,
* `partition`, `pick`, `plant`, `pluck`, `property`, `propertyOf`, `pull`, * `pairs`, `partial`, `partialRight`, `partition`, `pick`, `plant`, `pluck`,
* `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `reverse`, * `property`, `propertyOf`, `pull`, `pullAt`, `push`, `range`, `rearg`,
* `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`, `sortByOrder`, `splice`, * `reject`, `remove`, `rest`, `restParam`, `reverse`, `set`, `shuffle`,
* `spread`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, * `slice`, `sort`, `sortBy`, `sortByAll`, `sortByOrder`, `splice`, `spread`,
* `throttle`, `thru`, `times`, `toArray`, `toPlainObject`, `transform`, * `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`,
* `union`, `uniq`, `unshift`, `unzip`, `values`, `valuesIn`, `where`, * `thru`, `times`, `toArray`, `toPlainObject`, `transform`, `union`, `uniq`,
* `without`, `wrap`, `xor`, `zip`, and `zipObject` * `unshift`, `unzip`, `unzipWith`, `values`, `valuesIn`, `where`, `without`,
* `wrap`, `xor`, `zip`, `zipObject`, `zipWith`
* *
* The wrapper methods that are **not** chainable by default are: * The wrapper methods that are **not** chainable by default are:
* `add`, `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`, * `add`, `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`,
* `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, * `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`,
* `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`, * `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `get`,
* `identity`, `includes`, `indexOf`, `inRange`, `isArguments`, `isArray`, * `gt`, `gte`, `has`, `identity`, `includes`, `indexOf`, `inRange`, `isArguments`,
* `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`, `isFinite` * `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`,
* `isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`, `isObject`, * `isFinite` `isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`,
* `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `isTypedArray`, * `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`,
* `join`, `kebabCase`, `last`, `lastIndexOf`, `max`, `min`, `noConflict`, * `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `lt`, `lte`,
* `noop`, `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`, `random`, * `max`, `min`, `noConflict`, `noop`, `now`, `pad`, `padLeft`, `padRight`,
* `reduce`, `reduceRight`, `repeat`, `result`, `runInContext`, `shift`, `size`, * `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`,
* `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`, `startCase`, `startsWith`, * `runInContext`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`,
* `sum`, `template`, `trim`, `trimLeft`, `trimRight`, `trunc`, `unescape`, * `sortedLastIndex`, `startCase`, `startsWith`, `sum`, `template`, `trim`,
* `uniqueId`, `value`, and `words` * `trimLeft`, `trimRight`, `trunc`, `unescape`, `uniqueId`, `value`, and `words`
* *
* The wrapper method `sample` will return a wrapped value when `n` is provided, * The wrapper method `sample` will return a wrapped value when `n` is provided,
* otherwise an unwrapped value is returned. * otherwise an unwrapped value is returned.

View File

@@ -1,4 +1,4 @@
define(['../internal/baseAt', '../internal/baseFlatten', '../internal/getLength', '../internal/isLength', '../function/restParam', '../internal/toIterable'], function(baseAt, baseFlatten, getLength, isLength, restParam, toIterable) { define(['../internal/baseAt', '../internal/baseFlatten', '../function/restParam'], function(baseAt, baseFlatten, restParam) {
/** /**
* Creates an array of elements corresponding to the given keys, or indexes, * Creates an array of elements corresponding to the given keys, or indexes,
@@ -21,10 +21,6 @@ define(['../internal/baseAt', '../internal/baseFlatten', '../internal/getLength'
* // => ['barney', 'pebbles'] * // => ['barney', 'pebbles']
*/ */
var at = restParam(function(collection, props) { var at = restParam(function(collection, props) {
var length = collection ? getLength(collection) : 0;
if (isLength(length)) {
collection = toIterable(collection);
}
return baseAt(collection, baseFlatten(props)); return baseAt(collection, baseFlatten(props));
}); });

View File

@@ -4,13 +4,10 @@ define(['../internal/baseIndexOf', '../internal/getLength', '../lang/isArray', '
var nativeMax = Math.max; var nativeMax = Math.max;
/** /**
* Checks if `value` is in `collection` using `SameValueZero` for equality * Checks if `value` is in `collection` using
* comparisons. If `fromIndex` is negative, it is used as the offset from * [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* the end of `collection`. * for equality comparisons. If `fromIndex` is negative, it is used as the offset
* * from the end of `collection`.
* **Note:** [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* comparisons are like strict equality comparisons, e.g. `===`, except that
* `NaN` matches `NaN`.
* *
* @static * @static
* @memberOf _ * @memberOf _

View File

@@ -1,7 +1,7 @@
define(['../internal/baseEach', '../internal/getLength', '../internal/invokePath', '../internal/isKey', '../internal/isLength', '../function/restParam'], function(baseEach, getLength, invokePath, isKey, isLength, restParam) { define(['../internal/baseEach', '../internal/invokePath', '../internal/isArrayLike', '../internal/isKey', '../function/restParam'], function(baseEach, invokePath, isArrayLike, isKey, restParam) {
/** /**
* Invokes the method at `path` on each element in `collection`, returning * Invokes the method at `path` of each element in `collection`, returning
* an array of the results of each invoked method. Any additional arguments * an array of the results of each invoked method. Any additional arguments
* are provided to each invoked method. If `methodName` is a function it is * are provided to each invoked method. If `methodName` is a function it is
* invoked for, and `this` bound to, each element in `collection`. * invoked for, and `this` bound to, each element in `collection`.
@@ -26,11 +26,10 @@ define(['../internal/baseEach', '../internal/getLength', '../internal/invokePath
var index = -1, var index = -1,
isFunc = typeof path == 'function', isFunc = typeof path == 'function',
isProp = isKey(path), isProp = isKey(path),
length = getLength(collection), result = isArrayLike(collection) ? Array(collection.length) : [];
result = isLength(length) ? Array(length) : [];
baseEach(collection, function(value) { baseEach(collection, function(value) {
var func = isFunc ? path : (isProp && value != null && value[path]); var func = isFunc ? path : ((isProp && value != null) ? value[path] : null);
result[++index] = func ? func.apply(value, args) : invokePath(value, path, args); result[++index] = func ? func.apply(value, args) : invokePath(value, path, args);
}); });
return result; return result;

View File

@@ -16,14 +16,15 @@ define(['../internal/arrayMap', '../internal/baseCallback', '../internal/baseMap
* callback returns `true` for elements that have the properties of the given * callback returns `true` for elements that have the properties of the given
* object, else `false`. * object, else `false`.
* *
* Many lodash methods are guarded to work as interatees for methods like * Many lodash methods are guarded to work as iteratees for methods like
* `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`. * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
* *
* The guarded methods are: * The guarded methods are:
* `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`, `drop`, * `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`,
* `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`, `parseInt`, * `drop`, `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`,
* `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`, `trimLeft`, * `parseInt`, `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`,
* `trimRight`, `trunc`, `random`, `range`, `sample`, `some`, `uniq`, and `words` * `trimLeft`, `trimRight`, `trunc`, `random`, `range`, `sample`, `some`,
* `sum`, `uniq`, and `words`
* *
* @static * @static
* @memberOf _ * @memberOf _

View File

@@ -8,7 +8,7 @@ define(['../internal/arrayReduce', '../internal/baseEach', '../internal/createRe
* value. The `iteratee` is bound to `thisArg` and invoked with four arguments: * value. The `iteratee` is bound to `thisArg` and invoked with four arguments:
* (accumulator, value, index|key, collection). * (accumulator, value, index|key, collection).
* *
* Many lodash methods are guarded to work as interatees for methods like * Many lodash methods are guarded to work as iteratees for methods like
* `_.reduce`, `_.reduceRight`, and `_.transform`. * `_.reduce`, `_.reduceRight`, and `_.transform`.
* *
* The guarded methods are: * The guarded methods are:

View File

@@ -22,7 +22,7 @@ define(['../internal/arrayReduceRight', '../internal/baseEachRight', '../interna
* }, []); * }, []);
* // => [4, 5, 2, 3, 0, 1] * // => [4, 5, 2, 3, 0, 1]
*/ */
var reduceRight = createReduce(arrayReduceRight, baseEachRight); var reduceRight = createReduce(arrayReduceRight, baseEachRight);
return reduceRight; return reduceRight;
}); });

View File

@@ -4,17 +4,6 @@ define(['../internal/arrayFilter', '../internal/baseCallback', '../internal/base
* The opposite of `_.filter`; this method returns the elements of `collection` * The opposite of `_.filter`; this method returns the elements of `collection`
* that `predicate` does **not** return truthy for. * that `predicate` does **not** return truthy for.
* *
* If a property name is provided for `predicate` the created `_.property`
* style callback returns the property value of the given element.
*
* If a value is also provided for `thisArg` the created `_.matchesProperty`
* style callback returns `true` for elements that have a matching property
* value, else `false`.
*
* If an object is provided for `predicate` the created `_.matches` style
* callback returns `true` for elements that have the properties of the given
* object, else `false`.
*
* @static * @static
* @memberOf _ * @memberOf _
* @category Collection * @category Collection

View File

@@ -1,4 +1,4 @@
define(['../internal/baseRandom', '../internal/isIterateeCall', './shuffle', '../internal/toIterable'], function(baseRandom, isIterateeCall, shuffle, toIterable) { define(['../internal/baseRandom', '../internal/isIterateeCall', '../lang/toArray', '../internal/toIterable'], function(baseRandom, isIterateeCall, toArray, toIterable) {
/** 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;
@@ -30,8 +30,20 @@ define(['../internal/baseRandom', '../internal/isIterateeCall', './shuffle', '..
var length = collection.length; var length = collection.length;
return length > 0 ? collection[baseRandom(0, length - 1)] : undefined; return length > 0 ? collection[baseRandom(0, length - 1)] : undefined;
} }
var result = shuffle(collection); var index = -1,
result.length = nativeMin(n < 0 ? 0 : (+n || 0), result.length); result = toArray(collection),
length = result.length,
lastIndex = length - 1;
n = nativeMin(n < 0 ? 0 : (+n || 0), length);
while (++index < n) {
var rand = baseRandom(index, lastIndex),
value = result[rand];
result[rand] = result[index];
result[index] = value;
}
result.length = n;
return result; return result;
} }

View File

@@ -1,4 +1,7 @@
define(['../internal/baseRandom', '../internal/toIterable'], function(baseRandom, toIterable) { define(['./sample'], function(sample) {
/** Used as references for `-Infinity` and `Infinity`. */
var POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
/** /**
* Creates an array of shuffled values, using a version of the * Creates an array of shuffled values, using a version of the
@@ -15,20 +18,7 @@ define(['../internal/baseRandom', '../internal/toIterable'], function(baseRandom
* // => [4, 1, 3, 2] * // => [4, 1, 3, 2]
*/ */
function shuffle(collection) { function shuffle(collection) {
collection = toIterable(collection); return sample(collection, POSITIVE_INFINITY);
var index = -1,
length = collection.length,
result = Array(length);
while (++index < length) {
var rand = baseRandom(0, index);
if (index != rand) {
result[index] = result[rand];
}
result[rand] = collection[index];
}
return result;
} }
return shuffle; return shuffle;

View File

@@ -1,7 +1,7 @@
define(['../lang/isNative'], function(isNative) { define(['../internal/getNative'], function(getNative) {
/* Native method references for those with the same name as other `lodash` methods. */ /* Native method references for those with the same name as other `lodash` methods. */
var nativeNow = isNative(nativeNow = Date.now) && nativeNow; var nativeNow = getNative(Date, 'now');
/** /**
* Gets the number of milliseconds that have elapsed since the Unix epoch * Gets the number of milliseconds that have elapsed since the Unix epoch

View File

@@ -10,12 +10,13 @@ define(['../lang/isObject', '../date/now'], function(isObject, now) {
var nativeMax = Math.max; var nativeMax = Math.max;
/** /**
* Creates a function that delays invoking `func` until after `wait` milliseconds * Creates a debounced function that delays invoking `func` until after `wait`
* have elapsed since the last time it was invoked. The created function comes * milliseconds have elapsed since the last time the debounced function was
* with a `cancel` method to cancel delayed invocations. Provide an options * invoked. The debounced function comes with a `cancel` method to cancel
* object to indicate that `func` should be invoked on the leading and/or * delayed invocations. Provide an options object to indicate that `func`
* trailing edge of the `wait` timeout. Subsequent calls to the debounced * should be invoked on the leading and/or trailing edge of the `wait` timeout.
* function return the result of the last `func` invocation. * Subsequent calls to the debounced function return the result of the last
* `func` invocation.
* *
* **Note:** If `leading` and `trailing` options are `true`, `func` is invoked * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked
* on the trailing edge of the timeout only if the the debounced function is * on the trailing edge of the timeout only if the the debounced function is

View File

@@ -60,14 +60,14 @@ define(['../internal/MapCache'], function(MapCache) {
} }
var memoized = function() { var memoized = function() {
var args = arguments, var args = arguments,
cache = memoized.cache, key = resolver ? resolver.apply(this, args) : args[0],
key = resolver ? resolver.apply(this, args) : args[0]; cache = memoized.cache;
if (cache.has(key)) { if (cache.has(key)) {
return cache.get(key); return cache.get(key);
} }
var result = func.apply(this, args); var result = func.apply(this, args);
cache.set(key, result); memoized.cache = cache.set(key, result);
return result; return result;
}; };
memoized.cache = new memoize.Cache; memoized.cache = new memoize.Cache;

View File

@@ -11,12 +11,12 @@ define(['./debounce', '../lang/isObject'], function(debounce, isObject) {
}; };
/** /**
* Creates a function that only invokes `func` at most once per every `wait` * Creates a throttled function that only invokes `func` at most once per
* milliseconds. The created function comes with a `cancel` method to cancel * every `wait` milliseconds. The throttled function comes with a `cancel`
* delayed invocations. Provide an options object to indicate that `func` * method to cancel delayed invocations. Provide an options object to indicate
* should be invoked on the leading and/or trailing edge of the `wait` timeout. * that `func` should be invoked on the leading and/or trailing edge of the
* Subsequent calls to the throttled function return the result of the last * `wait` timeout. Subsequent calls to the throttled function return the
* `func` call. * result of the last `func` call.
* *
* **Note:** If `leading` and `trailing` options are `true`, `func` is invoked * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked
* on the trailing edge of the timeout only if the the throttled function is * on the trailing edge of the timeout only if the the throttled function is

View File

@@ -1,10 +1,10 @@
define(['./cachePush', '../lang/isNative', './root'], function(cachePush, isNative, root) { define(['./cachePush', './getNative', './root'], function(cachePush, getNative, root) {
/** Native method references. */ /** Native method references. */
var Set = isNative(Set = root.Set) && Set; var Set = getNative(root, 'Set');
/* Native method references for those with the same name as other `lodash` methods. */ /* Native method references for those with the same name as other `lodash` methods. */
var nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate; var nativeCreate = getNative(Object, 'create');
/** /**
* *

33
internal/arrayExtremum.js Normal file
View File

@@ -0,0 +1,33 @@
define([], function() {
/**
* A specialized version of `baseExtremum` for arrays which invokes `iteratee`
* with one argument: (value).
*
* @private
* @param {Array} array The array to iterate over.
* @param {Function} iteratee The function invoked per iteration.
* @param {Function} comparator The function used to compare values.
* @param {*} exValue The initial extremum value.
* @returns {*} Returns the extremum value.
*/
function arrayExtremum(array, iteratee, comparator, exValue) {
var index = -1,
length = array.length,
computed = exValue,
result = computed;
while (++index < length) {
var value = array[index],
current = +iteratee(value);
if (comparator(current, computed)) {
computed = current;
result = value;
}
}
return result;
}
return arrayExtremum;
});

View File

@@ -1,28 +0,0 @@
define([], function() {
/** Used as references for `-Infinity` and `Infinity`. */
var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY;
/**
* A specialized version of `_.max` for arrays without support for iteratees.
*
* @private
* @param {Array} array The array to iterate over.
* @returns {*} Returns the maximum value.
*/
function arrayMax(array) {
var index = -1,
length = array.length,
result = NEGATIVE_INFINITY;
while (++index < length) {
var value = array[index];
if (value > result) {
result = value;
}
}
return result;
}
return arrayMax;
});

View File

@@ -1,28 +0,0 @@
define([], function() {
/** Used as references for `-Infinity` and `Infinity`. */
var POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
/**
* A specialized version of `_.min` for arrays without support for iteratees.
*
* @private
* @param {Array} array The array to iterate over.
* @returns {*} Returns the minimum value.
*/
function arrayMin(array) {
var index = -1,
length = array.length,
result = POSITIVE_INFINITY;
while (++index < length) {
var value = array[index];
if (value < result) {
result = value;
}
}
return result;
}
return arrayMin;
});

View File

@@ -1,14 +1,8 @@
define(['./getSymbols', '../object/keys'], function(getSymbols, keys) { define(['../object/keys'], function(keys) {
/** 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 for native method references. */
var arrayProto = Array.prototype;
/** Native method references. */
var push = arrayProto.push;
/** /**
* A specialized version of `_.assign` for customizing assigned values without * A specialized version of `_.assign` for customizing assigned values without
* support for argument juggling, multiple sources, and `this` binding `customizer` * support for argument juggling, multiple sources, and `this` binding `customizer`
@@ -21,10 +15,8 @@ define(['./getSymbols', '../object/keys'], function(getSymbols, keys) {
* @returns {Object} Returns `object`. * @returns {Object} Returns `object`.
*/ */
function assignWith(object, source, customizer) { function assignWith(object, source, customizer) {
var props = keys(source);
push.apply(props, getSymbols(source));
var index = -1, var index = -1,
props = keys(source),
length = props.length; length = props.length;
while (++index < length) { while (++index < length) {

View File

@@ -1,23 +1,4 @@
define(['./baseCopy', './getSymbols', '../lang/isNative', '../object/keys'], function(baseCopy, getSymbols, isNative, keys) { define(['./baseCopy', '../object/keys'], function(baseCopy, keys) {
/** Native method references. */
var preventExtensions = isNative(Object.preventExtensions = Object.preventExtensions) && preventExtensions;
/** Used as `baseAssign`. */
var nativeAssign = (function() {
// Avoid `Object.assign` in Firefox 34-37 which have an early implementation
// with a now defunct try/catch behavior. See https://bugzilla.mozilla.org/show_bug.cgi?id=1103344
// for more details.
//
// Use `Object.preventExtensions` on a plain object instead of simply using
// `Object('x')` because Chrome and IE fail to throw an error when attempting
// to assign values to readonly indexes of strings in strict mode.
var object = { '1': 0 },
func = preventExtensions && isNative(func = Object.assign) && func;
try { func(preventExtensions(object), 'xo'); } catch(e) {}
return !object[1] && func;
}());
/** /**
* The base implementation of `_.assign` without support for argument juggling, * The base implementation of `_.assign` without support for argument juggling,
@@ -28,11 +9,11 @@ define(['./baseCopy', './getSymbols', '../lang/isNative', '../object/keys'], fun
* @param {Object} source The source object. * @param {Object} source The source object.
* @returns {Object} Returns `object`. * @returns {Object} Returns `object`.
*/ */
var baseAssign = nativeAssign || function(object, source) { function baseAssign(object, source) {
return source == null return source == null
? object ? object
: baseCopy(source, getSymbols(source), baseCopy(source, keys(source), object)); : baseCopy(source, keys(source), object);
}; }
return baseAssign; return baseAssign;
}); });

View File

@@ -1,4 +1,4 @@
define(['./isIndex', './isLength'], function(isIndex, isLength) { define(['./isArrayLike', './isIndex'], function(isArrayLike, isIndex) {
/** 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,8 +14,9 @@ define(['./isIndex', './isLength'], function(isIndex, isLength) {
*/ */
function baseAt(collection, props) { function baseAt(collection, props) {
var index = -1, var index = -1,
length = collection.length, isNil = collection == null,
isArr = isLength(length), isArr = !isNil && isArrayLike(collection),
length = isArr ? collection.length : 0,
propsLength = props.length, propsLength = props.length,
result = Array(propsLength); result = Array(propsLength);
@@ -24,7 +25,7 @@ define(['./isIndex', './isLength'], function(isIndex, isLength) {
if (isArr) { if (isArr) {
result[index] = isIndex(key, length) ? collection[key] : undefined; result[index] = isIndex(key, length) ? collection[key] : undefined;
} else { } else {
result[index] = collection[key]; result[index] = isNil ? undefined : collection[key];
} }
} }
return result; return result;

View File

@@ -8,19 +8,28 @@ define([], function() {
* sorts them in ascending order without guaranteeing a stable sort. * sorts them in ascending order without guaranteeing a stable sort.
* *
* @private * @private
* @param {*} value The value to compare to `other`. * @param {*} value The value to compare.
* @param {*} other The value to compare to `value`. * @param {*} other The other value to compare.
* @returns {number} Returns the sort order indicator for `value`. * @returns {number} Returns the sort order indicator for `value`.
*/ */
function baseCompareAscending(value, other) { function baseCompareAscending(value, other) {
if (value !== other) { if (value !== other) {
var valIsReflexive = value === value, var valIsNull = value === null,
valIsUndef = value === undefined,
valIsReflexive = value === value;
var othIsNull = other === null,
othIsUndef = other === undefined,
othIsReflexive = other === other; othIsReflexive = other === other;
if (value > other || !valIsReflexive || (value === undefined && othIsReflexive)) { if ((value > other && !othIsNull) || !valIsReflexive ||
(valIsNull && !othIsUndef && othIsReflexive) ||
(valIsUndef && othIsReflexive)) {
return 1; return 1;
} }
if (value < other || !othIsReflexive || (other === undefined && valIsReflexive)) { if ((value < other && !valIsNull) || !othIsReflexive ||
(othIsNull && !valIsUndef && valIsReflexive) ||
(othIsUndef && valIsReflexive)) {
return -1; return -1;
} }
} }

View File

@@ -1,4 +1,4 @@
define(['../lang/isObject', './root'], function(isObject, root) { define(['../lang/isObject'], function(isObject) {
/** /**
* The base implementation of `_.create` without support for assigning * The base implementation of `_.create` without support for assigning
@@ -9,14 +9,14 @@ define(['../lang/isObject', './root'], function(isObject, root) {
* @returns {Object} Returns the new object. * @returns {Object} Returns the new object.
*/ */
var baseCreate = (function() { var baseCreate = (function() {
function Object() {} function object() {}
return function(prototype) { return function(prototype) {
if (isObject(prototype)) { if (isObject(prototype)) {
Object.prototype = prototype; object.prototype = prototype;
var result = new Object; var result = new object;
Object.prototype = null; object.prototype = null;
} }
return result || root.Object(); return result || {};
}; };
}()); }());

View File

@@ -1,30 +1,24 @@
define(['./baseEach'], function(baseEach) { define(['./baseEach'], function(baseEach) {
/** Used as references for `-Infinity` and `Infinity`. */
var NEGATIVE_INFINITY = Number.NEGATIVE_INFINITY,
POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
/** /**
* Gets the extremum value of `collection` invoking `iteratee` for each value * Gets the extremum value of `collection` invoking `iteratee` for each value
* in `collection` to generate the criterion by which the value is ranked. * in `collection` to generate the criterion by which the value is ranked.
* The `iteratee` is invoked with three arguments: (value, index, collection). * The `iteratee` is invoked with three arguments: (value, index|key, collection).
* *
* @private * @private
* @param {Array|Object|string} collection The collection to iterate over. * @param {Array|Object|string} collection The collection to iterate over.
* @param {Function} iteratee The function invoked per iteration. * @param {Function} iteratee The function invoked per iteration.
* @param {boolean} [isMin] Specify returning the minimum, instead of the * @param {Function} comparator The function used to compare values.
* maximum, extremum value. * @param {*} exValue The initial extremum value.
* @returns {*} Returns the extremum value. * @returns {*} Returns the extremum value.
*/ */
function extremumBy(collection, iteratee, isMin) { function baseExtremum(collection, iteratee, comparator, exValue) {
var exValue = isMin ? POSITIVE_INFINITY : NEGATIVE_INFINITY, var computed = exValue,
computed = exValue,
result = computed; result = computed;
baseEach(collection, function(value, index, collection) { baseEach(collection, function(value, index, collection) {
var current = iteratee(value, index, collection); var current = +iteratee(value, index, collection);
if ((isMin ? (current < computed) : (current > computed)) || if (comparator(current, computed) || (current === exValue && current === result)) {
(current === exValue && current === result)) {
computed = current; computed = current;
result = value; result = value;
} }
@@ -32,5 +26,5 @@ define(['./baseEach'], function(baseEach) {
return result; return result;
} }
return extremumBy; return baseExtremum;
}); });

View File

@@ -1,4 +1,4 @@
define(['../lang/isArguments', '../lang/isArray', './isLength', './isObjectLike'], function(isArguments, isArray, isLength, isObjectLike) { define(['../lang/isArguments', '../lang/isArray', './isArrayLike', './isObjectLike'], function(isArguments, isArray, isArrayLike, isObjectLike) {
/** /**
* The base implementation of `_.flatten` with added support for restricting * The base implementation of `_.flatten` with added support for restricting
@@ -6,8 +6,8 @@ define(['../lang/isArguments', '../lang/isArray', './isLength', './isObjectLike'
* *
* @private * @private
* @param {Array} array The array to flatten. * @param {Array} array The array to flatten.
* @param {boolean} isDeep Specify a deep flatten. * @param {boolean} [isDeep] Specify a deep flatten.
* @param {boolean} isStrict Restrict flattening to arrays and `arguments` objects. * @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
* @returns {Array} Returns the new flattened array. * @returns {Array} Returns the new flattened array.
*/ */
function baseFlatten(array, isDeep, isStrict) { function baseFlatten(array, isDeep, isStrict) {
@@ -18,8 +18,8 @@ define(['../lang/isArguments', '../lang/isArray', './isLength', './isObjectLike'
while (++index < length) { while (++index < length) {
var value = array[index]; var value = array[index];
if (isObjectLike(value) && isArrayLike(value) &&
if (isObjectLike(value) && isLength(value.length) && (isArray(value) || isArguments(value))) { (isStrict || isArray(value) || isArguments(value))) {
if (isDeep) { if (isDeep) {
// Recursively flatten arrays (susceptible to call stack limits). // Recursively flatten arrays (susceptible to call stack limits).
value = baseFlatten(value, isDeep, isStrict); value = baseFlatten(value, isDeep, isStrict);
@@ -27,7 +27,6 @@ define(['../lang/isArguments', '../lang/isArray', './isLength', './isObjectLike'
var valIndex = -1, var valIndex = -1,
valLength = value.length; valLength = value.length;
result.length += valLength;
while (++valIndex < valLength) { while (++valIndex < valLength) {
result[++resIndex] = value[valIndex]; result[++resIndex] = value[valIndex];
} }

View File

@@ -20,13 +20,13 @@ define(['./toObject'], function(toObject) {
if (pathKey !== undefined && pathKey in toObject(object)) { if (pathKey !== undefined && pathKey in toObject(object)) {
path = [pathKey]; path = [pathKey];
} }
var index = -1, var index = 0,
length = path.length; length = path.length;
while (object != null && ++index < length) { while (object != null && index < length) {
var result = object = object[path[index]]; object = object[path[index++]];
} }
return result; return (index && index == length) ? object : undefined;
} }
return baseGet; return baseGet;

View File

@@ -1,4 +1,4 @@
define(['./baseIsEqualDeep'], function(baseIsEqualDeep) { define(['./baseIsEqualDeep', '../lang/isObject', './isObjectLike'], function(baseIsEqualDeep, isObject, isObjectLike) {
/** /**
* The base implementation of `_.isEqual` without support for `this` binding * The base implementation of `_.isEqual` without support for `this` binding
@@ -14,18 +14,10 @@ define(['./baseIsEqualDeep'], function(baseIsEqualDeep) {
* @returns {boolean} Returns `true` if the values are equivalent, else `false`. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
*/ */
function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) { function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) {
// Exit early for identical values.
if (value === other) { if (value === other) {
// Treat `+0` vs. `-0` as not equal. return true;
return value !== 0 || (1 / value == 1 / other);
} }
var valType = typeof value, if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
othType = typeof other;
// Exit early for unlike primitive values.
if ((valType != 'function' && valType != 'object' && othType != 'function' && othType != 'object') ||
value == null || other == null) {
// Return `false` unless both values are `NaN`.
return value !== value && other !== other; return value !== value && other !== other;
} }
return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB); return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB);

View File

@@ -62,11 +62,11 @@ define(['./equalArrays', './equalByTag', './equalObjects', '../lang/isArray', '.
return equalByTag(object, other, objTag); return equalByTag(object, other, objTag);
} }
if (!isLoose) { if (!isLoose) {
var valWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'), var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
othWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__'); othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
if (valWrapped || othWrapped) { if (objIsWrapped || othIsWrapped) {
return equalFunc(valWrapped ? object.value() : object, othWrapped ? other.value() : other, customizer, isLoose, stackA, stackB); return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, isLoose, stackA, stackB);
} }
} }
if (!isSameTag) { if (!isSameTag) {

View File

@@ -1,4 +1,4 @@
define(['./baseIsEqual'], function(baseIsEqual) { define(['./baseIsEqual', './toObject'], function(baseIsEqual, toObject) {
/** 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;
@@ -9,41 +9,43 @@ define(['./baseIsEqual'], function(baseIsEqual) {
* *
* @private * @private
* @param {Object} object The object to inspect. * @param {Object} object The object to inspect.
* @param {Array} props The source property names to match. * @param {Array} matchData The propery names, values, and compare flags to match.
* @param {Array} values The source values to match.
* @param {Array} strictCompareFlags Strict comparison flags for source values.
* @param {Function} [customizer] The function to customize comparing objects. * @param {Function} [customizer] The function to customize comparing objects.
* @returns {boolean} Returns `true` if `object` is a match, else `false`. * @returns {boolean} Returns `true` if `object` is a match, else `false`.
*/ */
function baseIsMatch(object, props, values, strictCompareFlags, customizer) { function baseIsMatch(object, matchData, customizer) {
var index = -1, var index = matchData.length,
length = props.length, length = index,
noCustomizer = !customizer; noCustomizer = !customizer;
while (++index < length) { if (object == null) {
if ((noCustomizer && strictCompareFlags[index]) return !length;
? values[index] !== object[props[index]] }
: !(props[index] in object) object = toObject(object);
while (index--) {
var data = matchData[index];
if ((noCustomizer && data[2])
? data[1] !== object[data[0]]
: !(data[0] in object)
) { ) {
return false; return false;
} }
} }
index = -1;
while (++index < length) { while (++index < length) {
var key = props[index], data = matchData[index];
var key = data[0],
objValue = object[key], objValue = object[key],
srcValue = values[index]; srcValue = data[1];
if (noCustomizer && strictCompareFlags[index]) { if (noCustomizer && data[2]) {
var result = objValue !== undefined || (key in object); if (objValue === undefined && !(key in object)) {
} else { return false;
result = customizer ? customizer(objValue, srcValue, key) : undefined; }
if (result === undefined) { } else {
result = baseIsEqual(srcValue, objValue, customizer, true); var result = customizer ? customizer(objValue, srcValue, key) : undefined;
if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, true) : result)) {
return false;
} }
}
if (!result) {
return false;
} }
} }
return true; return true;

View File

@@ -1,4 +1,4 @@
define(['./baseEach', './getLength', './isLength'], function(baseEach, getLength, isLength) { define(['./baseEach', './isArrayLike'], function(baseEach, isArrayLike) {
/** /**
* The base implementation of `_.map` without support for callback shorthands * The base implementation of `_.map` without support for callback shorthands
@@ -11,8 +11,7 @@ define(['./baseEach', './getLength', './isLength'], function(baseEach, getLength
*/ */
function baseMap(collection, iteratee) { function baseMap(collection, iteratee) {
var index = -1, var index = -1,
length = getLength(collection), result = isArrayLike(collection) ? Array(collection.length) : [];
result = isLength(length) ? Array(length) : [];
baseEach(collection, function(value, key, collection) { baseEach(collection, function(value, key, collection) {
result[++index] = iteratee(value, key, collection); result[++index] = iteratee(value, key, collection);

View File

@@ -1,4 +1,4 @@
define(['./baseIsMatch', '../utility/constant', './isStrictComparable', '../object/keys', './toObject'], function(baseIsMatch, constant, isStrictComparable, keys, toObject) { define(['./baseIsMatch', './getMatchData', './toObject'], function(baseIsMatch, getMatchData, toObject) {
/** 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;
@@ -11,35 +11,20 @@ define(['./baseIsMatch', '../utility/constant', './isStrictComparable', '../obje
* @returns {Function} Returns the new function. * @returns {Function} Returns the new function.
*/ */
function baseMatches(source) { function baseMatches(source) {
var props = keys(source), var matchData = getMatchData(source);
length = props.length; if (matchData.length == 1 && matchData[0][2]) {
var key = matchData[0][0],
value = matchData[0][1];
if (!length) { return function(object) {
return constant(true); if (object == null) {
} return false;
if (length == 1) { }
var key = props[0], return object[key] === value && (value !== undefined || (key in toObject(object)));
value = source[key]; };
if (isStrictComparable(value)) {
return function(object) {
if (object == null) {
return false;
}
return object[key] === value && (value !== undefined || (key in toObject(object)));
};
}
}
var values = Array(length),
strictCompareFlags = Array(length);
while (length--) {
value = source[props[length]];
values[length] = value;
strictCompareFlags[length] = isStrictComparable(value);
} }
return function(object) { return function(object) {
return object != null && baseIsMatch(toObject(object), props, values, strictCompareFlags); return baseIsMatch(object, matchData);
}; };
} }

View File

@@ -4,17 +4,16 @@ define(['./baseGet', './baseIsEqual', './baseSlice', '../lang/isArray', './isKey
var undefined; var undefined;
/** /**
* The base implementation of `_.matchesProperty` which does not which does * The base implementation of `_.matchesProperty` which does not clone `srcValue`.
* not clone `value`.
* *
* @private * @private
* @param {string} path The path of the property to get. * @param {string} path The path of the property to get.
* @param {*} value The value to compare. * @param {*} srcValue The value to compare.
* @returns {Function} Returns the new function. * @returns {Function} Returns the new function.
*/ */
function baseMatchesProperty(path, value) { function baseMatchesProperty(path, srcValue) {
var isArr = isArray(path), var isArr = isArray(path),
isCommon = isKey(path) && isStrictComparable(value), isCommon = isKey(path) && isStrictComparable(srcValue),
pathKey = (path + ''); pathKey = (path + '');
path = toPath(path); path = toPath(path);
@@ -32,9 +31,9 @@ define(['./baseGet', './baseIsEqual', './baseSlice', '../lang/isArray', './isKey
key = last(path); key = last(path);
object = toObject(object); object = toObject(object);
} }
return object[key] === value return object[key] === srcValue
? (value !== undefined || (key in object)) ? (srcValue !== undefined || (key in object))
: baseIsEqual(value, object[key], null, true); : baseIsEqual(srcValue, object[key], undefined, true);
}; };
} }

View File

@@ -1,14 +1,8 @@
define(['./arrayEach', './baseMergeDeep', './getSymbols', '../lang/isArray', './isLength', '../lang/isObject', './isObjectLike', '../lang/isTypedArray', '../object/keys'], function(arrayEach, baseMergeDeep, getSymbols, isArray, isLength, isObject, isObjectLike, isTypedArray, keys) { define(['./arrayEach', './baseMergeDeep', '../lang/isArray', './isArrayLike', '../lang/isObject', './isObjectLike', '../lang/isTypedArray', '../object/keys'], function(arrayEach, baseMergeDeep, isArray, isArrayLike, isObject, isObjectLike, isTypedArray, keys) {
/** 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 for native method references. */
var arrayProto = Array.prototype;
/** Native method references. */
var push = arrayProto.push;
/** /**
* The base implementation of `_.merge` without support for argument juggling, * The base implementation of `_.merge` without support for argument juggling,
* multiple sources, and `this` binding `customizer` functions. * multiple sources, and `this` binding `customizer` functions.
@@ -25,11 +19,9 @@ define(['./arrayEach', './baseMergeDeep', './getSymbols', '../lang/isArray', './
if (!isObject(object)) { if (!isObject(object)) {
return object; return object;
} }
var isSrcArr = isLength(source.length) && (isArray(source) || isTypedArray(source)); var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source)),
if (!isSrcArr) { props = isSrcArr ? null : keys(source);
var props = keys(source);
push.apply(props, getSymbols(source));
}
arrayEach(props || source, function(srcValue, key) { arrayEach(props || source, function(srcValue, key) {
if (props) { if (props) {
key = srcValue; key = srcValue;
@@ -48,7 +40,7 @@ define(['./arrayEach', './baseMergeDeep', './getSymbols', '../lang/isArray', './
if (isCommon) { if (isCommon) {
result = srcValue; result = srcValue;
} }
if ((isSrcArr || result !== undefined) && if ((result !== undefined || (isSrcArr && !(key in object))) &&
(isCommon || (result === result ? (result !== value) : (value === value)))) { (isCommon || (result === result ? (result !== value) : (value === value)))) {
object[key] = result; object[key] = result;
} }

View File

@@ -1,4 +1,4 @@
define(['./arrayCopy', './getLength', '../lang/isArguments', '../lang/isArray', './isLength', '../lang/isPlainObject', '../lang/isTypedArray', '../lang/toPlainObject'], function(arrayCopy, getLength, isArguments, isArray, isLength, isPlainObject, isTypedArray, toPlainObject) { define(['./arrayCopy', '../lang/isArguments', '../lang/isArray', './isArrayLike', '../lang/isPlainObject', '../lang/isTypedArray', '../lang/toPlainObject'], function(arrayCopy, isArguments, isArray, isArrayLike, isPlainObject, isTypedArray, toPlainObject) {
/** 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;
@@ -34,10 +34,10 @@ define(['./arrayCopy', './getLength', '../lang/isArguments', '../lang/isArray',
if (isCommon) { if (isCommon) {
result = srcValue; result = srcValue;
if (isLength(srcValue.length) && (isArray(srcValue) || isTypedArray(srcValue))) { if (isArrayLike(srcValue) && (isArray(srcValue) || isTypedArray(srcValue))) {
result = isArray(value) result = isArray(value)
? value ? value
: (getLength(value) ? arrayCopy(value) : []); : (isArrayLike(value) ? arrayCopy(value) : []);
} }
else if (isPlainObject(srcValue) || isArguments(srcValue)) { else if (isPlainObject(srcValue) || isArguments(srcValue)) {
result = isArguments(value) result = isArguments(value)

View File

@@ -16,9 +16,9 @@ define(['./isIndex'], function(isIndex) {
* @returns {Array} Returns `array`. * @returns {Array} Returns `array`.
*/ */
function basePullAt(array, indexes) { function basePullAt(array, indexes) {
var length = indexes.length; var length = array ? indexes.length : 0;
while (length--) { while (length--) {
var index = parseFloat(indexes[length]); var index = indexes[length];
if (index != previous && isIndex(index)) { if (index != previous && isIndex(index)) {
var previous = index; var previous = index;
splice.call(array, index, 1); splice.call(array, index, 1);

View File

@@ -1,7 +1,7 @@
define([], function() { define([], function() {
/** /**
* Converts `value` to a string if it is not one. An empty string is returned * Converts `value` to a string if it's not one. An empty string is returned
* for `null` or `undefined` values. * for `null` or `undefined` values.
* *
* @private * @private

View File

@@ -1,7 +1,7 @@
define(['./binaryIndexBy', '../utility/identity'], function(binaryIndexBy, identity) { define(['./binaryIndexBy', '../utility/identity'], function(binaryIndexBy, identity) {
/** Used as references for the maximum length and index of an array. */ /** Used as references for the maximum length and index of an array. */
var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1, var MAX_ARRAY_LENGTH = 4294967295,
HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1; HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
/** /**
@@ -24,7 +24,7 @@ define(['./binaryIndexBy', '../utility/identity'], function(binaryIndexBy, ident
var mid = (low + high) >>> 1, var mid = (low + high) >>> 1,
computed = array[mid]; computed = array[mid];
if (retHighest ? (computed <= value) : (computed < value)) { if ((retHighest ? (computed <= value) : (computed < value)) && computed !== null) {
low = mid + 1; low = mid + 1;
} else { } else {
high = mid; high = mid;

View File

@@ -10,8 +10,8 @@ define([], function() {
var nativeMin = Math.min; var nativeMin = Math.min;
/** Used as references for the maximum length and index of an array. */ /** Used as references for the maximum length and index of an array. */
var MAX_ARRAY_LENGTH = Math.pow(2, 32) - 1, var MAX_ARRAY_LENGTH = 4294967295,
MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1; MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1;
/** /**
* This function is like `binaryIndex` except that it invokes `iteratee` for * This function is like `binaryIndex` except that it invokes `iteratee` for
@@ -32,17 +32,23 @@ define([], function() {
var low = 0, var low = 0,
high = array ? array.length : 0, high = array ? array.length : 0,
valIsNaN = value !== value, valIsNaN = value !== value,
valIsNull = value === null,
valIsUndef = value === undefined; valIsUndef = value === undefined;
while (low < high) { while (low < high) {
var mid = floor((low + high) / 2), var mid = floor((low + high) / 2),
computed = iteratee(array[mid]), computed = iteratee(array[mid]),
isDef = computed !== undefined,
isReflexive = computed === computed; isReflexive = computed === computed;
if (valIsNaN) { if (valIsNaN) {
var setLow = isReflexive || retHighest; var setLow = isReflexive || retHighest;
} else if (valIsNull) {
setLow = isReflexive && isDef && (retHighest || computed != null);
} else if (valIsUndef) { } else if (valIsUndef) {
setLow = isReflexive && (retHighest || computed !== undefined); setLow = isReflexive && (retHighest || isDef);
} else if (computed == null) {
setLow = false;
} else { } else {
setLow = retHighest ? (computed <= value) : (computed < value); setLow = retHighest ? (computed <= value) : (computed < value);
} }

View File

@@ -1,10 +1,10 @@
define(['../utility/constant', '../lang/isNative', './root'], function(constant, isNative, root) { define(['../utility/constant', './getNative', './root'], function(constant, getNative, root) {
/** Native method references. */ /** Native method references. */
var ArrayBuffer = isNative(ArrayBuffer = root.ArrayBuffer) && ArrayBuffer, var ArrayBuffer = getNative(root, 'ArrayBuffer'),
bufferSlice = isNative(bufferSlice = ArrayBuffer && new ArrayBuffer(0).slice) && bufferSlice, bufferSlice = getNative(ArrayBuffer && new ArrayBuffer(0), 'slice'),
floor = Math.floor, floor = Math.floor,
Uint8Array = isNative(Uint8Array = root.Uint8Array) && Uint8Array; Uint8Array = getNative(root, 'Uint8Array');
/** Used to clone array buffers. */ /** Used to clone array buffers. */
var Float64Array = (function() { var Float64Array = (function() {
@@ -12,10 +12,10 @@ define(['../utility/constant', '../lang/isNative', './root'], function(constant,
// where the array buffer's `byteLength` is not a multiple of the typed // where the array buffer's `byteLength` is not a multiple of the typed
// array's `BYTES_PER_ELEMENT`. // array's `BYTES_PER_ELEMENT`.
try { try {
var func = isNative(func = root.Float64Array) && func, var func = getNative(root, 'Float64Array'),
result = new func(new ArrayBuffer(10), 0, 1) && func; result = new func(new ArrayBuffer(10), 0, 1) && func;
} catch(e) {} } catch(e) {}
return result; return result || null;
}()); }());
/** Used as the size, in bytes, of each `Float64Array` element. */ /** Used as the size, in bytes, of each `Float64Array` element. */

View File

@@ -1,15 +0,0 @@
define([], function() {
/**
* Used by `_.max` and `_.min` as the default callback for string values.
*
* @private
* @param {string} string The string to inspect.
* @returns {number} Returns the code unit of the first character of the string.
*/
function charAtCallback(string) {
return string.charCodeAt(0);
}
return charAtCallback;
});

View File

@@ -25,12 +25,12 @@ define([], function() {
while (++argsIndex < argsLength) { while (++argsIndex < argsLength) {
result[argsIndex] = args[argsIndex]; result[argsIndex] = args[argsIndex];
} }
var pad = argsIndex; var offset = argsIndex;
while (++rightIndex < rightLength) { while (++rightIndex < rightLength) {
result[pad + rightIndex] = partials[rightIndex]; result[offset + rightIndex] = partials[rightIndex];
} }
while (++holdersIndex < holdersLength) { while (++holdersIndex < holdersLength) {
result[pad + holders[holdersIndex]] = args[argsIndex++]; result[offset + holders[holdersIndex]] = args[argsIndex++];
} }
return result; return result;
} }

View File

@@ -1,5 +1,8 @@
define(['./bindCallback', './isIterateeCall', '../function/restParam'], function(bindCallback, isIterateeCall, restParam) { define(['./bindCallback', './isIterateeCall', '../function/restParam'], function(bindCallback, isIterateeCall, restParam) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** /**
* Creates a function that assigns properties of source object(s) to a given * Creates a function that assigns properties of source object(s) to a given
* destination object. * destination object.
@@ -14,19 +17,19 @@ define(['./bindCallback', './isIterateeCall', '../function/restParam'], function
return restParam(function(object, sources) { return restParam(function(object, sources) {
var index = -1, var index = -1,
length = object == null ? 0 : sources.length, length = object == null ? 0 : sources.length,
customizer = length > 2 && sources[length - 2], customizer = length > 2 ? sources[length - 2] : undefined,
guard = length > 2 && sources[2], guard = length > 2 ? sources[2] : undefined,
thisArg = length > 1 && sources[length - 1]; thisArg = length > 1 ? sources[length - 1] : undefined;
if (typeof customizer == 'function') { if (typeof customizer == 'function') {
customizer = bindCallback(customizer, thisArg, 5); customizer = bindCallback(customizer, thisArg, 5);
length -= 2; length -= 2;
} else { } else {
customizer = typeof thisArg == 'function' ? thisArg : null; customizer = typeof thisArg == 'function' ? thisArg : undefined;
length -= (customizer ? 1 : 0); length -= (customizer ? 1 : 0);
} }
if (guard && isIterateeCall(sources[0], sources[1], guard)) { if (guard && isIterateeCall(sources[0], sources[1], guard)) {
customizer = length < 3 ? null : customizer; customizer = length < 3 ? undefined : customizer;
length = 1; length = 1;
} }
while (++index < length) { while (++index < length) {

View File

@@ -1,10 +1,10 @@
define(['./SetCache', '../utility/constant', '../lang/isNative', './root'], function(SetCache, constant, isNative, root) { define(['./SetCache', '../utility/constant', './getNative', './root'], function(SetCache, constant, getNative, root) {
/** Native method references. */ /** Native method references. */
var Set = isNative(Set = root.Set) && Set; var Set = getNative(root, 'Set');
/* Native method references for those with the same name as other `lodash` methods. */ /* Native method references for those with the same name as other `lodash` methods. */
var nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate; var nativeCreate = getNative(Object, 'create');
/** /**
* Creates a `Set` cache object to optimize linear searches of large arrays. * Creates a `Set` cache object to optimize linear searches of large arrays.

View File

@@ -10,8 +10,20 @@ define(['./baseCreate', '../lang/isObject'], function(baseCreate, isObject) {
*/ */
function createCtorWrapper(Ctor) { function createCtorWrapper(Ctor) {
return function() { return function() {
// Use a `switch` statement to work with class constructors.
// See https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-function-objects-call-thisargument-argumentslist
// for more details.
var args = arguments;
switch (args.length) {
case 0: return new Ctor;
case 1: return new Ctor(args[0]);
case 2: return new Ctor(args[0], args[1]);
case 3: return new Ctor(args[0], args[1], args[2]);
case 4: return new Ctor(args[0], args[1], args[2], args[3]);
case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
}
var thisBinding = baseCreate(Ctor.prototype), var thisBinding = baseCreate(Ctor.prototype),
result = Ctor.apply(thisBinding, arguments); result = Ctor.apply(thisBinding, args);
// Mimic the constructor's `return` behavior. // Mimic the constructor's `return` behavior.
// See https://es5.github.io/#x13.2.2 for more details. // See https://es5.github.io/#x13.2.2 for more details.

View File

@@ -1,31 +1,27 @@
define(['./baseCallback', './charAtCallback', './extremumBy', '../lang/isArray', './isIterateeCall', '../lang/isString', './toIterable'], function(baseCallback, charAtCallback, extremumBy, isArray, isIterateeCall, isString, toIterable) { define(['./arrayExtremum', './baseCallback', './baseExtremum', './isIterateeCall', './toIterable'], function(arrayExtremum, baseCallback, baseExtremum, isIterateeCall, toIterable) {
/** /**
* Creates a `_.max` or `_.min` function. * Creates a `_.max` or `_.min` function.
* *
* @private * @private
* @param {Function} arrayFunc The function to get the extremum value from an array. * @param {Function} comparator The function used to compare values.
* @param {boolean} [isMin] Specify returning the minimum, instead of the maximum, * @param {*} exValue The initial extremum value.
* extremum value.
* @returns {Function} Returns the new extremum function. * @returns {Function} Returns the new extremum function.
*/ */
function createExtremum(arrayFunc, isMin) { function createExtremum(comparator, exValue) {
return function(collection, iteratee, thisArg) { return function(collection, iteratee, thisArg) {
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
iteratee = null; iteratee = null;
} }
var noIteratee = iteratee == null; iteratee = baseCallback(iteratee, thisArg, 3);
if (iteratee.length == 1) {
iteratee = noIteratee ? iteratee : baseCallback(iteratee, thisArg, 3); collection = toIterable(collection);
if (noIteratee) { var result = arrayExtremum(collection, iteratee, comparator, exValue);
var isArr = isArray(collection); if (!(collection.length && result === exValue)) {
if (!isArr && isString(collection)) { return result;
iteratee = charAtCallback;
} else {
return arrayFunc(isArr ? collection : toIterable(collection));
} }
} }
return extremumBy(collection, iteratee, isMin); return baseExtremum(collection, iteratee, comparator, exValue);
}; };
} }

View File

@@ -19,7 +19,7 @@ define(['./baseCallback', './baseFind', './baseFindIndex', '../lang/isArray'], f
return index > -1 ? collection[index] : undefined; return index > -1 ? collection[index] : undefined;
} }
return baseFind(collection, predicate, eachFunc); return baseFind(collection, predicate, eachFunc);
} };
} }
return createFind; return createFind;

View File

@@ -1,5 +1,11 @@
define(['./LodashWrapper', './getData', './getFuncName', '../lang/isArray', './isLaziable'], function(LodashWrapper, getData, getFuncName, isArray, isLaziable) { define(['./LodashWrapper', './getData', './getFuncName', '../lang/isArray', './isLaziable'], function(LodashWrapper, getData, getFuncName, isArray, isLaziable) {
/** Used to compose bitmasks for wrapper metadata. */
var CURRY_FLAG = 8,
PARTIAL_FLAG = 32,
ARY_FLAG = 128,
REARG_FLAG = 256;
/** 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';
@@ -12,11 +18,8 @@ define(['./LodashWrapper', './getData', './getFuncName', '../lang/isArray', './i
*/ */
function createFlow(fromRight) { function createFlow(fromRight) {
return function() { return function() {
var length = arguments.length;
if (!length) {
return function() { return arguments[0]; };
}
var wrapper, var wrapper,
length = arguments.length,
index = fromRight ? length : -1, index = fromRight ? length : -1,
leftIndex = 0, leftIndex = 0,
funcs = Array(length); funcs = Array(length);
@@ -26,16 +29,18 @@ define(['./LodashWrapper', './getData', './getFuncName', '../lang/isArray', './i
if (typeof func != 'function') { if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT); throw new TypeError(FUNC_ERROR_TEXT);
} }
var funcName = wrapper ? '' : getFuncName(func); if (!wrapper && LodashWrapper.prototype.thru && getFuncName(func) == 'wrapper') {
wrapper = funcName == 'wrapper' ? new LodashWrapper([]) : wrapper; wrapper = new LodashWrapper([]);
}
} }
index = wrapper ? -1 : length; index = wrapper ? -1 : length;
while (++index < length) { while (++index < length) {
func = funcs[index]; func = funcs[index];
funcName = getFuncName(func);
var data = funcName == 'wrapper' ? getData(func) : null; var funcName = getFuncName(func),
if (data && isLaziable(data[0])) { data = funcName == 'wrapper' ? getData(func) : null;
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);
@@ -47,7 +52,7 @@ define(['./LodashWrapper', './getData', './getFuncName', '../lang/isArray', './i
return wrapper.plant(args[0]).value(); return wrapper.plant(args[0]).value();
} }
var index = 0, var index = 0,
result = funcs[index].apply(this, args); result = length ? funcs[index].apply(this, args) : args[0];
while (++index < length) { while (++index < length) {
result = funcs[index].call(this, result); result = funcs[index].call(this, result);

View File

@@ -39,10 +39,8 @@ define(['./arrayCopy', './composeArgs', './composeArgsRight', './createCtorWrapp
isBindKey = bitmask & BIND_KEY_FLAG, isBindKey = bitmask & BIND_KEY_FLAG,
isCurry = bitmask & CURRY_FLAG, isCurry = bitmask & CURRY_FLAG,
isCurryBound = bitmask & CURRY_BOUND_FLAG, isCurryBound = bitmask & CURRY_BOUND_FLAG,
isCurryRight = bitmask & CURRY_RIGHT_FLAG; isCurryRight = bitmask & CURRY_RIGHT_FLAG,
Ctor = isBindKey ? null : createCtorWrapper(func);
var Ctor = !isBindKey && createCtorWrapper(func),
key = func;
function wrapper() { function wrapper() {
// Avoid `arguments` object use disqualifying optimizations by // Avoid `arguments` object use disqualifying optimizations by
@@ -89,17 +87,18 @@ define(['./arrayCopy', './composeArgs', './composeArgsRight', './createCtorWrapp
return result; return result;
} }
} }
var thisBinding = isBind ? thisArg : this; var thisBinding = isBind ? thisArg : this,
if (isBindKey) { fn = isBindKey ? thisBinding[func] : func;
func = thisBinding[key];
}
if (argPos) { if (argPos) {
args = reorder(args, argPos); args = reorder(args, argPos);
} }
if (isAry && ary < args.length) { if (isAry && ary < args.length) {
args.length = ary; args.length = ary;
} }
var fn = (this && this !== root && this instanceof wrapper) ? (Ctor || createCtorWrapper(func)) : func; if (this && this !== root && this instanceof wrapper) {
fn = Ctor || createCtorWrapper(func);
}
return fn.apply(thisBinding, args); return fn.apply(thisBinding, args);
} }
return wrapper; return wrapper;

View File

@@ -0,0 +1,26 @@
define(['./baseCallback', './baseForOwn'], function(baseCallback, baseForOwn) {
/**
* Creates a function for `_.mapKeys` or `_.mapValues`.
*
* @private
* @param {boolean} [isMapKeys] Specify mapping keys instead of values.
* @returns {Function} Returns the new map function.
*/
function createObjectMapper(isMapKeys) {
return function(object, iteratee, thisArg) {
var result = {};
iteratee = baseCallback(iteratee, thisArg, 3);
baseForOwn(object, function(value, key, object) {
var mapped = iteratee(value, key, object);
key = isMapKeys ? mapped : key;
value = isMapKeys ? value : mapped;
result[key] = value;
});
return result;
};
}
return createObjectMapper;
});

View File

@@ -10,7 +10,7 @@ define(['./baseToString', './createPadding'], function(baseToString, createPaddi
function createPadDir(fromRight) { function createPadDir(fromRight) {
return function(string, length, chars) { return function(string, length, chars) {
string = baseToString(string); string = baseToString(string);
return string && ((fromRight ? string : '') + createPadding(string, length, chars) + (fromRight ? '' : string)); return (fromRight ? string : '') + createPadding(string, length, chars) + (fromRight ? '' : string);
}; };
} }

View File

@@ -1,4 +1,4 @@
define([], function() { define(['./arraySome'], function(arraySome) {
/** 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;
@@ -20,40 +20,35 @@ define([], function() {
function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) { function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) {
var index = -1, var index = -1,
arrLength = array.length, arrLength = array.length,
othLength = other.length, othLength = other.length;
result = true;
if (arrLength != othLength && !(isLoose && othLength > arrLength)) { if (arrLength != othLength && !(isLoose && othLength > arrLength)) {
return false; return false;
} }
// Deep compare the contents, ignoring non-numeric properties. // Ignore non-index properties.
while (result && ++index < arrLength) { while (++index < arrLength) {
var arrValue = array[index], var arrValue = array[index],
othValue = other[index]; othValue = other[index],
result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined;
result = undefined; if (result !== undefined) {
if (customizer) { if (result) {
result = isLoose continue;
? customizer(othValue, arrValue, index)
: customizer(arrValue, othValue, index);
}
if (result === undefined) {
// Recursively compare arrays (susceptible to call stack limits).
if (isLoose) {
var othIndex = othLength;
while (othIndex--) {
othValue = other[othIndex];
result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
if (result) {
break;
}
}
} else {
result = (arrValue && arrValue === othValue) || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
} }
return false;
}
// Recursively compare arrays (susceptible to call stack limits).
if (isLoose) {
if (!arraySome(other, function(othValue) {
return arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
})) {
return false;
}
} else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB))) {
return false;
} }
} }
return !!result; return true;
} }
return equalArrays; return equalArrays;

View File

@@ -36,8 +36,7 @@ define([], function() {
// Treat `NaN` vs. `NaN` as equal. // Treat `NaN` vs. `NaN` as equal.
return (object != +object) return (object != +object)
? other != +other ? other != +other
// But, treat `-0` vs. `+0` as not equal. : object == +other;
: (object == 0 ? ((1 / object) == (1 / other)) : object == +other);
case regexpTag: case regexpTag:
case stringTag: case stringTag:

View File

@@ -32,29 +32,22 @@ define(['../object/keys'], function(keys) {
if (objLength != othLength && !isLoose) { if (objLength != othLength && !isLoose) {
return false; return false;
} }
var skipCtor = isLoose, var index = objLength;
index = -1; while (index--) {
var key = objProps[index];
while (++index < objLength) { if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) {
var key = objProps[index], return false;
result = isLoose ? key in other : hasOwnProperty.call(other, key);
if (result) {
var objValue = object[key],
othValue = other[key];
result = undefined;
if (customizer) {
result = isLoose
? customizer(othValue, objValue, key)
: customizer(objValue, othValue, key);
}
if (result === undefined) {
// Recursively compare objects (susceptible to call stack limits).
result = (objValue && objValue === othValue) || equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB);
}
} }
if (!result) { }
var skipCtor = isLoose;
while (++index < objLength) {
key = objProps[index];
var objValue = object[key],
othValue = other[key],
result = customizer ? customizer(isLoose ? othValue : objValue, isLoose? objValue : othValue, key) : undefined;
// Recursively compare objects (susceptible to call stack limits).
if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) {
return false; return false;
} }
skipCtor || (skipCtor = key == 'constructor'); skipCtor || (skipCtor = key == 'constructor');

View File

@@ -1,4 +1,4 @@
define(['./baseProperty', '../utility/constant', './realNames', '../support'], function(baseProperty, constant, realNames, support) { define(['./realNames'], function(realNames) {
/** /**
* Gets the name of `func`. * Gets the name of `func`.
@@ -7,29 +7,20 @@ define(['./baseProperty', '../utility/constant', './realNames', '../support'], f
* @param {Function} func The function to query. * @param {Function} func The function to query.
* @returns {string} Returns the function name. * @returns {string} Returns the function name.
*/ */
var getFuncName = (function() { function getFuncName(func) {
if (!support.funcNames) { var result = func.name,
return constant(''); array = realNames[result],
} length = array ? array.length : 0;
if (constant.name == 'constant') {
return baseProperty('name');
}
return function(func) {
var result = func.name,
array = realNames[result],
length = array ? array.length : 0;
while (length--) { while (length--) {
var data = array[length], var data = array[length],
otherFunc = data.func; otherFunc = data.func;
if (otherFunc == null || otherFunc == func) {
if (otherFunc == null || otherFunc == func) { return data.name;
return data.name;
}
} }
return result; }
}; return result;
}()); }
return getFuncName; return getFuncName;
}); });

View File

@@ -4,7 +4,7 @@ define(['./baseProperty'], function(baseProperty) {
* Gets the "length" property value of `object`. * Gets the "length" property value of `object`.
* *
* **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792) * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
* in Safari on iOS 8.1 ARM64. * that affects Safari on at least iOS 8.1-8.3 ARM64.
* *
* @private * @private
* @param {Object} object The object to query. * @param {Object} object The object to query.

21
internal/getMatchData.js Normal file
View File

@@ -0,0 +1,21 @@
define(['./isStrictComparable', '../object/pairs'], function(isStrictComparable, pairs) {
/**
* Gets the propery names, values, and compare flags of `object`.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the match data of `object`.
*/
function getMatchData(object) {
var result = pairs(object),
length = result.length;
while (length--) {
result[length][2] = isStrictComparable(result[length][1]);
}
return result;
}
return getMatchData;
});

20
internal/getNative.js Normal file
View File

@@ -0,0 +1,20 @@
define(['../lang/isNative'], function(isNative) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/**
* Gets the native function at `key` of `object`.
*
* @private
* @param {Object} object The object to query.
* @param {string} key The key of the method to get.
* @returns {*} Returns the function if it's native, else `undefined`.
*/
function getNative(object, key) {
var value = object == null ? undefined : object[key];
return isNative(value) ? value : undefined;
}
return getNative;
});

View File

@@ -1,18 +0,0 @@
define(['../utility/constant', '../lang/isNative', './toObject'], function(constant, isNative, toObject) {
/** Native method references. */
var getOwnPropertySymbols = isNative(getOwnPropertySymbols = Object.getOwnPropertySymbols) && getOwnPropertySymbols;
/**
* Creates an array of the own symbols of `object`.
*
* @private
* @param {Object} object The object to query.
* @returns {Array} Returns the array of symbols.
*/
var getSymbols = !getOwnPropertySymbols ? constant([]) : function(object) {
return getOwnPropertySymbols(toObject(object));
};
return getSymbols;
});

15
internal/isArrayLike.js Normal file
View File

@@ -0,0 +1,15 @@
define(['./getLength', './isLength'], function(getLength, isLength) {
/**
* Checks if `value` is array-like.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is array-like, else `false`.
*/
function isArrayLike(value) {
return value != null && isLength(getLength(value));
}
return isArrayLike;
});

View File

@@ -1,10 +1,13 @@
define([], function() { define([], function() {
/** Used to detect unsigned integer values. */
var reIsUint = /^\d+$/;
/** /**
* Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer) * Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
* of an array-like value. * of an array-like value.
*/ */
var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1; var MAX_SAFE_INTEGER = 9007199254740991;
/** /**
* Checks if `value` is a valid array-like index. * Checks if `value` is a valid array-like index.
@@ -15,7 +18,7 @@ define([], function() {
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`. * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
*/ */
function isIndex(value, length) { function isIndex(value, length) {
value = +value; value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
length = length == null ? MAX_SAFE_INTEGER : length; length = length == null ? MAX_SAFE_INTEGER : length;
return value > -1 && value % 1 == 0 && value < length; return value > -1 && value % 1 == 0 && value < length;
} }

View File

@@ -1,4 +1,4 @@
define(['./getLength', './isIndex', './isLength', '../lang/isObject'], function(getLength, isIndex, isLength, isObject) { define(['./isArrayLike', './isIndex', '../lang/isObject'], function(isArrayLike, isIndex, isObject) {
/** /**
* Checks if the provided arguments are from an iteratee call. * Checks if the provided arguments are from an iteratee call.
@@ -14,13 +14,9 @@ define(['./getLength', './isIndex', './isLength', '../lang/isObject'], function(
return false; return false;
} }
var type = typeof index; var type = typeof index;
if (type == 'number') { if (type == 'number'
var length = getLength(object), ? (isArrayLike(object) && isIndex(index, object.length))
prereq = isLength(length) && isIndex(index, length); : (type == 'string' && index in object)) {
} else {
prereq = type == 'string' && index in object;
}
if (prereq) {
var other = object[index]; var other = object[index];
return value === value ? (value === other) : (other !== other); return value === value ? (value === other) : (other !== other);
} }

View File

@@ -1,7 +1,7 @@
define(['../lang/isArray', './toObject'], function(isArray, toObject) { define(['../lang/isArray', './toObject'], function(isArray, toObject) {
/** Used to match property names within property paths. */ /** Used to match property names within property paths. */
var reIsDeepProp = /\.|\[(?:[^[\]]+|(["'])(?:(?!\1)[^\n\\]|\\.)*?)\1\]/, var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,
reIsPlainProp = /^\w*$/; reIsPlainProp = /^\w*$/;
/** /**

View File

@@ -1,4 +1,4 @@
define(['./LazyWrapper', './getFuncName', '../chain/lodash'], function(LazyWrapper, getFuncName, lodash) { define(['./LazyWrapper', './getData', './getFuncName', '../chain/lodash'], function(LazyWrapper, getData, getFuncName, lodash) {
/** /**
* Checks if `func` has a lazy counterpart. * Checks if `func` has a lazy counterpart.
@@ -9,7 +9,15 @@ define(['./LazyWrapper', './getFuncName', '../chain/lodash'], function(LazyWrapp
*/ */
function isLaziable(func) { function isLaziable(func) {
var funcName = getFuncName(func); var funcName = getFuncName(func);
return !!funcName && func === lodash[funcName] && funcName in LazyWrapper.prototype; if (!(funcName in LazyWrapper.prototype)) {
return false;
}
var other = lodash[funcName];
if (func === other) {
return true;
}
var data = getData(other);
return !!data && func === data[0];
} }
return isLaziable; return isLaziable;

View File

@@ -4,7 +4,7 @@ define([], function() {
* Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer) * Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
* of an array-like value. * of an array-like value.
*/ */
var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1; var MAX_SAFE_INTEGER = 9007199254740991;
/** /**
* Checks if `value` is a valid array-like length. * Checks if `value` is a valid array-like length.

View File

@@ -9,7 +9,7 @@ define(['../lang/isObject'], function(isObject) {
* equality comparisons, else `false`. * equality comparisons, else `false`.
*/ */
function isStrictComparable(value) { function isStrictComparable(value) {
return value === value && (value === 0 ? ((1 / value) > 0) : !isObject(value)); return value === value && !isObject(value);
} }
return isStrictComparable; return isStrictComparable;

View File

@@ -1,7 +1,7 @@
define(['../lang/isNative', './root'], function(isNative, root) { define(['./getNative', './root'], function(getNative, root) {
/** Native method references. */ /** Native method references. */
var WeakMap = isNative(WeakMap = root.WeakMap) && WeakMap; var WeakMap = getNative(root, 'WeakMap');
/** Used to store function metadata. */ /** Used to store function metadata. */
var metaMap = WeakMap && new WeakMap; var metaMap = WeakMap && new WeakMap;

View File

@@ -1,7 +1,7 @@
define(['./toObject'], function(toObject) { define(['./toObject'], function(toObject) {
/** /**
* A specialized version of `_.pick` that picks `object` properties specified * A specialized version of `_.pick` which picks `object` properties specified
* by `props`. * by `props`.
* *
* @private * @private

View File

@@ -1,7 +1,7 @@
define(['./baseForIn'], function(baseForIn) { define(['./baseForIn'], function(baseForIn) {
/** /**
* A specialized version of `_.pick` that picks `object` properties `predicate` * A specialized version of `_.pick` which picks `object` properties `predicate`
* returns truthy for. * returns truthy for.
* *
* @private * @private

View File

@@ -24,7 +24,7 @@ define([], function() {
/** /**
* Used as a reference to the global object. * Used as a reference to the global object.
* *
* The `this` value is used if it is 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 !== (this && this.window)) && freeWindow) || freeSelf || this; var root = freeGlobal || ((freeWindow !== (this && this.window)) && freeWindow) || freeSelf || this;

View File

@@ -1,4 +1,4 @@
define(['../lang/isArguments', '../lang/isArray', './isIndex', './isLength', '../object/keysIn', '../support'], function(isArguments, isArray, isIndex, isLength, keysIn, support) { define(['../lang/isArguments', '../lang/isArray', './isIndex', './isLength', '../object/keysIn'], function(isArguments, isArray, isIndex, isLength, keysIn) {
/** Used for native method references. */ /** Used for native method references. */
var objectProto = Object.prototype; var objectProto = Object.prototype;
@@ -19,8 +19,8 @@ define(['../lang/isArguments', '../lang/isArray', './isIndex', './isLength', '..
propsLength = props.length, propsLength = props.length,
length = propsLength && object.length; length = propsLength && object.length;
var allowIndexes = length && isLength(length) && var allowIndexes = !!length && isLength(length) &&
(isArray(object) || (support.nonEnumArgs && isArguments(object))); (isArray(object) || isArguments(object));
var index = -1, var index = -1,
result = []; result = [];

View File

@@ -1,7 +1,7 @@
define(['./getLength', './isLength', '../lang/isObject', '../object/values'], function(getLength, isLength, isObject, values) { define(['./isArrayLike', '../lang/isObject', '../object/values'], function(isArrayLike, isObject, values) {
/** /**
* Converts `value` to an array-like object if it is not one. * Converts `value` to an array-like object if it's not one.
* *
* @private * @private
* @param {*} value The value to process. * @param {*} value The value to process.
@@ -11,7 +11,7 @@ define(['./getLength', './isLength', '../lang/isObject', '../object/values'], fu
if (value == null) { if (value == null) {
return []; return [];
} }
if (!isLength(getLength(value))) { if (!isArrayLike(value)) {
return values(value); return values(value);
} }
return isObject(value) ? value : Object(value); return isObject(value) ? value : Object(value);

View File

@@ -1,7 +1,7 @@
define(['../lang/isObject'], function(isObject) { define(['../lang/isObject'], function(isObject) {
/** /**
* Converts `value` to an object if it is not one. * Converts `value` to an object if it's not one.
* *
* @private * @private
* @param {*} value The value to process. * @param {*} value The value to process.

View File

@@ -7,7 +7,7 @@ define(['./baseToString', '../lang/isArray'], function(baseToString, isArray) {
var reEscapeChar = /\\(\\)?/g; var reEscapeChar = /\\(\\)?/g;
/** /**
* Converts `value` to property path array if it is not one. * Converts `value` to property path array if it's not one.
* *
* @private * @private
* @param {*} value The value to process. * @param {*} value The value to process.

View File

@@ -1,7 +1,10 @@
define(['./lang/clone', './lang/cloneDeep', './lang/isArguments', './lang/isArray', './lang/isBoolean', './lang/isDate', './lang/isElement', './lang/isEmpty', './lang/isEqual', './lang/isError', './lang/isFinite', './lang/isFunction', './lang/isMatch', './lang/isNaN', './lang/isNative', './lang/isNull', './lang/isNumber', './lang/isObject', './lang/isPlainObject', './lang/isRegExp', './lang/isString', './lang/isTypedArray', './lang/isUndefined', './lang/toArray', './lang/toPlainObject'], function(clone, cloneDeep, isArguments, isArray, isBoolean, isDate, isElement, isEmpty, isEqual, isError, isFinite, isFunction, isMatch, isNaN, isNative, isNull, isNumber, isObject, isPlainObject, isRegExp, isString, isTypedArray, isUndefined, toArray, toPlainObject) { define(['./lang/clone', './lang/cloneDeep', './lang/eq', './lang/gt', './lang/gte', './lang/isArguments', './lang/isArray', './lang/isBoolean', './lang/isDate', './lang/isElement', './lang/isEmpty', './lang/isEqual', './lang/isError', './lang/isFinite', './lang/isFunction', './lang/isMatch', './lang/isNaN', './lang/isNative', './lang/isNull', './lang/isNumber', './lang/isObject', './lang/isPlainObject', './lang/isRegExp', './lang/isString', './lang/isTypedArray', './lang/isUndefined', './lang/lt', './lang/lte', './lang/toArray', './lang/toPlainObject'], function(clone, cloneDeep, eq, gt, gte, isArguments, isArray, isBoolean, isDate, isElement, isEmpty, isEqual, isError, isFinite, isFunction, isMatch, isNaN, isNative, isNull, isNumber, isObject, isPlainObject, isRegExp, isString, isTypedArray, isUndefined, lt, lte, toArray, toPlainObject) {
return { return {
'clone': clone, 'clone': clone,
'cloneDeep': cloneDeep, 'cloneDeep': cloneDeep,
'eq': eq,
'gt': gt,
'gte': gte,
'isArguments': isArguments, 'isArguments': isArguments,
'isArray': isArray, 'isArray': isArray,
'isBoolean': isBoolean, 'isBoolean': isBoolean,
@@ -23,6 +26,8 @@ define(['./lang/clone', './lang/cloneDeep', './lang/isArguments', './lang/isArra
'isString': isString, 'isString': isString,
'isTypedArray': isTypedArray, 'isTypedArray': isTypedArray,
'isUndefined': isUndefined, 'isUndefined': isUndefined,
'lt': lt,
'lte': lte,
'toArray': toArray, 'toArray': toArray,
'toPlainObject': toPlainObject 'toPlainObject': toPlainObject
}; };

View File

@@ -60,8 +60,9 @@ define(['../internal/baseClone', '../internal/bindCallback', '../internal/isIter
customizer = isDeep; customizer = isDeep;
isDeep = false; isDeep = false;
} }
customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1); return typeof customizer == 'function'
return baseClone(value, isDeep, customizer); ? baseClone(value, isDeep, bindCallback(customizer, thisArg, 1))
: baseClone(value, isDeep);
} }
return clone; return clone;

View File

@@ -46,8 +46,9 @@ define(['../internal/baseClone', '../internal/bindCallback'], function(baseClone
* // => 20 * // => 20
*/ */
function cloneDeep(value, customizer, thisArg) { function cloneDeep(value, customizer, thisArg) {
customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 1); return typeof customizer == 'function'
return baseClone(value, true, customizer); ? baseClone(value, true, bindCallback(customizer, thisArg, 1))
: baseClone(value, true);
} }
return cloneDeep; return cloneDeep;

3
lang/eq.js Normal file
View File

@@ -0,0 +1,3 @@
define(["./isEqual"], function(isEqual) {
return isEqual;
});

28
lang/gt.js Normal file
View File

@@ -0,0 +1,28 @@
define([], function() {
/**
* Checks if `value` is greater than `other`.
*
* @static
* @memberOf _
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if `value` is greater than `other`, else `false`.
* @example
*
* _.gt(3, 1);
* // => true
*
* _.gt(3, 3);
* // => false
*
* _.gt(1, 3);
* // => false
*/
function gt(value, other) {
return value > other;
}
return gt;
});

28
lang/gte.js Normal file
View File

@@ -0,0 +1,28 @@
define([], function() {
/**
* Checks if `value` is greater than or equal to `other`.
*
* @static
* @memberOf _
* @category Lang
* @param {*} value The value to compare.
* @param {*} other The other value to compare.
* @returns {boolean} Returns `true` if `value` is greater than or equal to `other`, else `false`.
* @example
*
* _.gte(3, 1);
* // => true
*
* _.gte(3, 3);
* // => true
*
* _.gte(1, 3);
* // => false
*/
function gte(value, other) {
return value >= other;
}
return gte;
});

View File

@@ -1,7 +1,4 @@
define(['../internal/isLength', '../internal/isObjectLike'], function(isLength, isObjectLike) { define(['../internal/isArrayLike', '../internal/isObjectLike'], function(isArrayLike, isObjectLike) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/** `Object#toString` result references. */ /** `Object#toString` result references. */
var argsTag = '[object Arguments]'; var argsTag = '[object Arguments]';
@@ -32,8 +29,7 @@ define(['../internal/isLength', '../internal/isObjectLike'], function(isLength,
* // => false * // => false
*/ */
function isArguments(value) { function isArguments(value) {
var length = isObjectLike(value) ? value.length : undefined; return isObjectLike(value) && isArrayLike(value) && objToString.call(value) == argsTag;
return isLength(length) && objToString.call(value) == argsTag;
} }
return isArguments; return isArguments;

View File

@@ -1,4 +1,4 @@
define(['../internal/isLength', './isNative', '../internal/isObjectLike'], function(isLength, isNative, isObjectLike) { define(['../internal/getNative', '../internal/isLength', '../internal/isObjectLike'], function(getNative, isLength, isObjectLike) {
/** `Object#toString` result references. */ /** `Object#toString` result references. */
var arrayTag = '[object Array]'; var arrayTag = '[object Array]';
@@ -13,7 +13,7 @@ define(['../internal/isLength', './isNative', '../internal/isObjectLike'], funct
var objToString = objectProto.toString; var objToString = objectProto.toString;
/* Native method references for those with the same name as other `lodash` methods. */ /* Native method references for those with the same name as other `lodash` methods. */
var nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray; var nativeIsArray = getNative(Array, 'isArray');
/** /**
* Checks if `value` is classified as an `Array` object. * Checks if `value` is classified as an `Array` object.

View File

@@ -1,4 +1,4 @@
define(['../internal/getLength', './isArguments', './isArray', './isFunction', '../internal/isLength', '../internal/isObjectLike', './isString', '../object/keys'], function(getLength, isArguments, isArray, isFunction, isLength, isObjectLike, isString, keys) { define(['./isArguments', './isArray', '../internal/isArrayLike', './isFunction', '../internal/isObjectLike', './isString', '../object/keys'], function(isArguments, isArray, isArrayLike, isFunction, isObjectLike, isString, keys) {
/** /**
* Checks if `value` is empty. A value is considered empty unless it is an * Checks if `value` is empty. A value is considered empty unless it is an
@@ -31,10 +31,9 @@ define(['../internal/getLength', './isArguments', './isArray', './isFunction', '
if (value == null) { if (value == null) {
return true; return true;
} }
var length = getLength(value); if (isArrayLike(value) && (isArray(value) || isString(value) || isArguments(value) ||
if (isLength(length) && (isArray(value) || isString(value) || isArguments(value) ||
(isObjectLike(value) && isFunction(value.splice)))) { (isObjectLike(value) && isFunction(value.splice)))) {
return !length; return !value.length;
} }
return !keys(value).length; return !keys(value).length;
} }

View File

@@ -1,4 +1,4 @@
define(['../internal/baseIsEqual', '../internal/bindCallback', '../internal/isStrictComparable'], function(baseIsEqual, bindCallback, isStrictComparable) { define(['../internal/baseIsEqual', '../internal/bindCallback'], function(baseIsEqual, bindCallback) {
/** 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,6 +18,7 @@ define(['../internal/baseIsEqual', '../internal/bindCallback', '../internal/isSt
* *
* @static * @static
* @memberOf _ * @memberOf _
* @alias eq
* @category Lang * @category Lang
* @param {*} value The value to compare. * @param {*} value The value to compare.
* @param {*} other The other value to compare. * @param {*} other The other value to compare.
@@ -47,12 +48,9 @@ define(['../internal/baseIsEqual', '../internal/bindCallback', '../internal/isSt
* // => true * // => true
*/ */
function isEqual(value, other, customizer, thisArg) { function isEqual(value, other, customizer, thisArg) {
customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 3); customizer = typeof customizer == 'function' ? bindCallback(customizer, thisArg, 3) : undefined;
if (!customizer && isStrictComparable(value) && isStrictComparable(other)) {
return value === other;
}
var result = customizer ? customizer(value, other) : undefined; var result = customizer ? customizer(value, other) : undefined;
return result === undefined ? baseIsEqual(value, other, customizer) : !!result; return result === undefined ? baseIsEqual(value, other, customizer) : !!result;
} }
return isEqual; return isEqual;

View File

@@ -1,8 +1,8 @@
define(['./isNative', '../internal/root'], function(isNative, root) { define(['../internal/getNative', '../internal/root'], function(getNative, root) {
/* Native method references for those with the same name as other `lodash` methods. */ /* Native method references for those with the same name as other `lodash` methods. */
var nativeIsFinite = root.isFinite, var nativeIsFinite = root.isFinite,
nativeNumIsFinite = isNative(nativeNumIsFinite = Number.isFinite) && nativeNumIsFinite; nativeNumIsFinite = getNative(Number, 'isFinite');
/** /**
* Checks if `value` is a finite primitive number. * Checks if `value` is a finite primitive number.

View File

@@ -1,4 +1,4 @@
define(['../internal/baseIsFunction', './isNative', '../internal/root'], function(baseIsFunction, isNative, root) { define(['../internal/baseIsFunction', '../internal/getNative', '../internal/root'], function(baseIsFunction, getNative, root) {
/** `Object#toString` result references. */ /** `Object#toString` result references. */
var funcTag = '[object Function]'; var funcTag = '[object Function]';
@@ -13,7 +13,7 @@ define(['../internal/baseIsFunction', './isNative', '../internal/root'], functio
var objToString = objectProto.toString; var objToString = objectProto.toString;
/** Native method references. */ /** Native method references. */
var Uint8Array = isNative(Uint8Array = root.Uint8Array) && Uint8Array; var Uint8Array = getNative(root, 'Uint8Array');
/** /**
* Checks if `value` is classified as a `Function` object. * Checks if `value` is classified as a `Function` object.

View File

@@ -1,4 +1,4 @@
define(['../internal/baseIsMatch', '../internal/bindCallback', '../internal/isStrictComparable', '../object/keys', '../internal/toObject'], function(baseIsMatch, bindCallback, isStrictComparable, keys, toObject) { define(['../internal/baseIsMatch', '../internal/bindCallback', '../internal/getMatchData'], function(baseIsMatch, bindCallback, getMatchData) {
/** 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;
@@ -43,33 +43,8 @@ define(['../internal/baseIsMatch', '../internal/bindCallback', '../internal/isSt
* // => true * // => true
*/ */
function isMatch(object, source, customizer, thisArg) { function isMatch(object, source, customizer, thisArg) {
var props = keys(source), customizer = typeof customizer == 'function' ? bindCallback(customizer, thisArg, 3) : undefined;
length = props.length; return baseIsMatch(object, getMatchData(source), customizer);
if (!length) {
return true;
}
if (object == null) {
return false;
}
customizer = typeof customizer == 'function' && bindCallback(customizer, thisArg, 3);
object = toObject(object);
if (!customizer && length == 1) {
var key = props[0],
value = source[key];
if (isStrictComparable(value)) {
return value === object[key] && (value !== undefined || (key in object));
}
}
var values = Array(length),
strictCompareFlags = Array(length);
while (length--) {
value = values[length] = source[props[length]];
strictCompareFlags[length] = isStrictComparable(value);
}
return baseIsMatch(object, props, values, strictCompareFlags, customizer);
} }
return isMatch; return isMatch;

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