Compare commits

..

8 Commits

Author SHA1 Message Date
John-David Dalton
9724afd7a6 Bump to v3.6.0. 2015-12-16 17:49:07 -08:00
John-David Dalton
707fe171fc Bump to v3.5.0. 2015-12-16 17:48:35 -08:00
John-David Dalton
4ce1d5ddd3 Bump to v3.4.0. 2015-12-16 17:48:03 -08:00
John-David Dalton
7a82a3d77b Bump to v3.3.1. 2015-12-16 17:47:30 -08:00
John-David Dalton
f8e4370129 Bump to v3.3.0. 2015-12-16 17:46:57 -08:00
John-David Dalton
3ccb5e7da3 Bump to v3.2.0. 2015-12-16 17:46:22 -08:00
jdalton
1608d89174 Bump to v3.1.0. 2015-12-16 17:45:39 -08:00
jdalton
3b2df88eab Bump to v3.0.1. 2015-05-19 22:26:03 -07:00
276 changed files with 5315 additions and 3177 deletions

View File

@@ -1,5 +1,5 @@
Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
Based on Underscore.js 1.7.0, copyright 2009-2015 Jeremy Ashkenas,
Based on Underscore.js, copyright 2009-2015 Jeremy Ashkenas,
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
Permission is hereby granted, free of charge, to any person obtaining

View File

@@ -1,4 +1,4 @@
# lodash v3.0.0
# lodash v3.6.0
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.

View File

@@ -1,4 +1,4 @@
define(['./array/chunk', './array/compact', './array/difference', './array/drop', './array/dropRight', './array/dropRightWhile', './array/dropWhile', './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, 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/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) {
return {
'chunk': chunk,
'compact': compact,
@@ -7,6 +7,7 @@ define(['./array/chunk', './array/compact', './array/difference', './array/drop'
'dropRight': dropRight,
'dropRightWhile': dropRightWhile,
'dropWhile': dropWhile,
'fill': fill,
'findIndex': findIndex,
'findLastIndex': findLastIndex,
'first': first,

View File

@@ -15,7 +15,7 @@ define(['../internal/baseSlice', '../internal/isIterateeCall'], function(baseSli
* @memberOf _
* @category Array
* @param {Array} array The array to process.
* @param {numer} [size=1] The length of each chunk.
* @param {number} [size=1] The length of each chunk.
* @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
* @returns {Array} Returns the new array containing chunks.
* @example

View File

@@ -1,13 +1,12 @@
define(['../internal/baseDifference', '../internal/baseFlatten', '../lang/isArguments', '../lang/isArray'], function(baseDifference, baseFlatten, isArguments, isArray) {
define(['../internal/baseDifference', '../internal/baseFlatten', '../lang/isArguments', '../lang/isArray', '../function/restParam'], function(baseDifference, baseFlatten, isArguments, isArray, restParam) {
/**
* Creates an array excluding all values of the provided arrays using
* `SameValueZero` for equality comparisons.
*
* **Note:** `SameValueZero` comparisons are like strict equality comparisons,
* e.g. `===`, except that `NaN` matches `NaN`. See the
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* for more details.
* **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
* @memberOf _
@@ -17,21 +16,14 @@ define(['../internal/baseDifference', '../internal/baseFlatten', '../lang/isArgu
* @returns {Array} Returns the new array of filtered values.
* @example
*
* _.difference([1, 2, 3], [5, 2, 10]);
* _.difference([1, 2, 3], [4, 2]);
* // => [1, 3]
*/
function difference() {
var index = -1,
length = arguments.length;
while (++index < length) {
var value = arguments[index];
if (isArray(value) || isArguments(value)) {
break;
}
}
return baseDifference(value, baseFlatten(arguments, false, true, ++index));
}
var difference = restParam(function(array, values) {
return (isArray(array) || isArguments(array))
? baseDifference(array, baseFlatten(values, false, true))
: [];
});
return difference;
});

View File

@@ -5,7 +5,6 @@ define(['../internal/baseSlice', '../internal/isIterateeCall'], function(baseSli
*
* @static
* @memberOf _
* @type Function
* @category Array
* @param {Array} array The array to query.
* @param {number} [n=1] The number of elements to drop.

View File

@@ -5,7 +5,6 @@ define(['../internal/baseSlice', '../internal/isIterateeCall'], function(baseSli
*
* @static
* @memberOf _
* @type Function
* @category Array
* @param {Array} array The array to query.
* @param {number} [n=1] The number of elements to drop.

View File

@@ -1,53 +1,58 @@
define(['../internal/baseCallback', '../internal/baseSlice'], function(baseCallback, baseSlice) {
define(['../internal/baseCallback', '../internal/baseWhile'], function(baseCallback, baseWhile) {
/**
* Creates a slice of `array` excluding elements dropped from the end.
* Elements are dropped until `predicate` returns falsey. The predicate is
* bound to `thisArg` and invoked with three arguments; (value, index, array).
* bound to `thisArg` and invoked with three arguments: (value, index, array).
*
* If a property name is provided for `predicate` the created "_.property"
* If a property name is provided for `predicate` the created `_.property`
* style callback returns the property value of the given element.
*
* If an object is provided for `predicate` the created "_.matches" style
* callback returns `true` for elements that have the properties of the given
* 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 match the properties of the given
* object, else `false`.
*
* @static
* @memberOf _
* @type Function
* @category Array
* @param {Array} array The array to query.
* @param {Function|Object|string} [predicate=_.identity] The function invoked
* per element.
* per iteration.
* @param {*} [thisArg] The `this` binding of `predicate`.
* @returns {Array} Returns the slice of `array`.
* @example
*
* _.dropRightWhile([1, 2, 3], function(n) { return n > 1; });
* _.dropRightWhile([1, 2, 3], function(n) {
* return n > 1;
* });
* // => [1]
*
* var users = [
* { 'user': 'barney', 'status': 'busy', 'active': false },
* { 'user': 'fred', 'status': 'busy', 'active': true },
* { 'user': 'pebbles', 'status': 'away', 'active': true }
* { 'user': 'barney', 'active': true },
* { 'user': 'fred', 'active': false },
* { 'user': 'pebbles', 'active': false }
* ];
*
* // using the "_.property" callback shorthand
* _.pluck(_.dropRightWhile(users, 'active'), 'user');
* // using the `_.matches` callback shorthand
* _.pluck(_.dropRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user');
* // => ['barney', 'fred']
*
* // using the `_.matchesProperty` callback shorthand
* _.pluck(_.dropRightWhile(users, 'active', false), 'user');
* // => ['barney']
*
* // using the "_.matches" callback shorthand
* _.pluck(_.dropRightWhile(users, { 'status': 'away' }), 'user');
* // => ['barney', 'fred']
* // using the `_.property` callback shorthand
* _.pluck(_.dropRightWhile(users, 'active'), 'user');
* // => ['barney', 'fred', 'pebbles']
*/
function dropRightWhile(array, predicate, thisArg) {
var length = array ? array.length : 0;
if (!length) {
return [];
}
predicate = baseCallback(predicate, thisArg, 3);
while (length-- && predicate(array[length], length, array)) {}
return baseSlice(array, 0, length + 1);
return (array && array.length)
? baseWhile(array, baseCallback(predicate, thisArg, 3), true, true)
: [];
}
return dropRightWhile;

View File

@@ -1,54 +1,58 @@
define(['../internal/baseCallback', '../internal/baseSlice'], function(baseCallback, baseSlice) {
define(['../internal/baseCallback', '../internal/baseWhile'], function(baseCallback, baseWhile) {
/**
* Creates a slice of `array` excluding elements dropped from the beginning.
* Elements are dropped until `predicate` returns falsey. The predicate is
* bound to `thisArg` and invoked with three arguments; (value, index, array).
* bound to `thisArg` and invoked with three arguments: (value, index, array).
*
* If a property name is provided for `predicate` the created "_.property"
* If a property name is provided for `predicate` the created `_.property`
* style callback returns the property value of the given element.
*
* If an object is provided for `predicate` the created "_.matches" style
* 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
* @memberOf _
* @type Function
* @category Array
* @param {Array} array The array to query.
* @param {Function|Object|string} [predicate=_.identity] The function invoked
* per element.
* per iteration.
* @param {*} [thisArg] The `this` binding of `predicate`.
* @returns {Array} Returns the slice of `array`.
* @example
*
* _.dropWhile([1, 2, 3], function(n) { return n < 3; });
* _.dropWhile([1, 2, 3], function(n) {
* return n < 3;
* });
* // => [3]
*
* var users = [
* { 'user': 'barney', 'status': 'busy', 'active': true },
* { 'user': 'fred', 'status': 'busy', 'active': false },
* { 'user': 'pebbles', 'status': 'away', 'active': true }
* { 'user': 'barney', 'active': false },
* { 'user': 'fred', 'active': false },
* { 'user': 'pebbles', 'active': true }
* ];
*
* // using the "_.property" callback shorthand
* _.pluck(_.dropWhile(users, 'active'), 'user');
* // using the `_.matches` callback shorthand
* _.pluck(_.dropWhile(users, { 'user': 'barney', 'active': false }), 'user');
* // => ['fred', 'pebbles']
*
* // using the "_.matches" callback shorthand
* _.pluck(_.dropWhile(users, { 'status': 'busy' }), 'user');
* // using the `_.matchesProperty` callback shorthand
* _.pluck(_.dropWhile(users, 'active', false), 'user');
* // => ['pebbles']
*
* // using the `_.property` callback shorthand
* _.pluck(_.dropWhile(users, 'active'), 'user');
* // => ['barney', 'fred', 'pebbles']
*/
function dropWhile(array, predicate, thisArg) {
var length = array ? array.length : 0;
if (!length) {
return [];
}
var index = -1;
predicate = baseCallback(predicate, thisArg, 3);
while (++index < length && predicate(array[index], index, array)) {}
return baseSlice(array, index);
return (array && array.length)
? baseWhile(array, baseCallback(predicate, thisArg, 3), true)
: [];
}
return dropWhile;

44
array/fill.js Normal file
View File

@@ -0,0 +1,44 @@
define(['../internal/baseFill', '../internal/isIterateeCall'], function(baseFill, isIterateeCall) {
/**
* Fills elements of `array` with `value` from `start` up to, but not
* including, `end`.
*
* **Note:** This method mutates `array`.
*
* @static
* @memberOf _
* @category Array
* @param {Array} array The array to fill.
* @param {*} value The value to fill `array` with.
* @param {number} [start=0] The start position.
* @param {number} [end=array.length] The end position.
* @returns {Array} Returns `array`.
* @example
*
* var array = [1, 2, 3];
*
* _.fill(array, 'a');
* console.log(array);
* // => ['a', 'a', 'a']
*
* _.fill(Array(3), 2);
* // => [2, 2, 2]
*
* _.fill([4, 6, 8], '*', 1, 2);
* // => [4, '*', 8]
*/
function fill(array, value, start, end) {
var length = array ? array.length : 0;
if (!length) {
return [];
}
if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
start = 0;
end = length;
}
return baseFill(array, value, start, end);
}
return fill;
});

View File

@@ -1,13 +1,17 @@
define(['../internal/baseCallback'], function(baseCallback) {
define(['../internal/createFindIndex'], function(createFindIndex) {
/**
* This method is like `_.find` except that it returns the index of the first
* element `predicate` returns truthy for, instead of the element itself.
* element `predicate` returns truthy for instead of the element itself.
*
* If a property name is provided for `predicate` the created "_.property"
* If a property name is provided for `predicate` the created `_.property`
* style callback returns the property value of the given element.
*
* If an object is provided for `predicate` the created "_.matches" style
* 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`.
*
@@ -16,41 +20,35 @@ define(['../internal/baseCallback'], function(baseCallback) {
* @category Array
* @param {Array} array The array to search.
* @param {Function|Object|string} [predicate=_.identity] The function invoked
* per iteration. If a property name or object is provided it is used to
* create a "_.property" or "_.matches" style callback respectively.
* per iteration.
* @param {*} [thisArg] The `this` binding of `predicate`.
* @returns {number} Returns the index of the found element, else `-1`.
* @example
*
* var users = [
* { 'user': 'barney', 'age': 36, 'active': false },
* { 'user': 'fred', 'age': 40, 'active': true },
* { 'user': 'pebbles', 'age': 1, 'active': false }
* { 'user': 'barney', 'active': false },
* { 'user': 'fred', 'active': false },
* { 'user': 'pebbles', 'active': true }
* ];
*
* _.findIndex(users, function(chr) { return chr.age < 40; });
* _.findIndex(users, function(chr) {
* return chr.user == 'barney';
* });
* // => 0
*
* // using the "_.matches" callback shorthand
* _.findIndex(users, { 'age': 1 });
* // => 2
*
* // using the "_.property" callback shorthand
* _.findIndex(users, 'active');
* // using the `_.matches` callback shorthand
* _.findIndex(users, { 'user': 'fred', 'active': false });
* // => 1
*
* // using the `_.matchesProperty` callback shorthand
* _.findIndex(users, 'active', false);
* // => 0
*
* // using the `_.property` callback shorthand
* _.findIndex(users, 'active');
* // => 2
*/
function findIndex(array, predicate, thisArg) {
var index = -1,
length = array ? array.length : 0;
predicate = baseCallback(predicate, thisArg, 3);
while (++index < length) {
if (predicate(array[index], index, array)) {
return index;
}
}
return -1;
}
var findIndex = createFindIndex();
return findIndex;
});

View File

@@ -1,13 +1,17 @@
define(['../internal/baseCallback'], function(baseCallback) {
define(['../internal/createFindIndex'], function(createFindIndex) {
/**
* This method is like `_.findIndex` except that it iterates over elements
* of `collection` from right to left.
*
* If a property name is provided for `predicate` the created "_.property"
* If a property name is provided for `predicate` the created `_.property`
* style callback returns the property value of the given element.
*
* If an object is provided for `predicate` the created "_.matches" style
* 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`.
*
@@ -16,39 +20,35 @@ define(['../internal/baseCallback'], function(baseCallback) {
* @category Array
* @param {Array} array The array to search.
* @param {Function|Object|string} [predicate=_.identity] The function invoked
* per iteration. If a property name or object is provided it is used to
* create a "_.property" or "_.matches" style callback respectively.
* per iteration.
* @param {*} [thisArg] The `this` binding of `predicate`.
* @returns {number} Returns the index of the found element, else `-1`.
* @example
*
* var users = [
* { 'user': 'barney', 'age': 36, 'active': true },
* { 'user': 'fred', 'age': 40, 'active': false },
* { 'user': 'pebbles', 'age': 1, 'active': false }
* { 'user': 'barney', 'active': true },
* { 'user': 'fred', 'active': false },
* { 'user': 'pebbles', 'active': false }
* ];
*
* _.findLastIndex(users, function(chr) { return chr.age < 40; });
* _.findLastIndex(users, function(chr) {
* return chr.user == 'pebbles';
* });
* // => 2
*
* // using the "_.matches" callback shorthand
* _.findLastIndex(users, { 'age': 40 });
* // => 1
* // using the `_.matches` callback shorthand
* _.findLastIndex(users, { 'user': 'barney', 'active': true });
* // => 0
*
* // using the "_.property" callback shorthand
* // using the `_.matchesProperty` callback shorthand
* _.findLastIndex(users, 'active', false);
* // => 2
*
* // using the `_.property` callback shorthand
* _.findLastIndex(users, 'active');
* // => 0
*/
function findLastIndex(array, predicate, thisArg) {
var length = array ? array.length : 0;
predicate = baseCallback(predicate, thisArg, 3);
while (length--) {
if (predicate(array[length], length, array)) {
return length;
}
}
return -1;
}
var findLastIndex = createFindIndex(true);
return findLastIndex;
});

View File

@@ -13,12 +13,12 @@ define(['../internal/baseFlatten', '../internal/isIterateeCall'], function(baseF
* @returns {Array} Returns the new flattened array.
* @example
*
* _.flatten([1, [2], [3, [[4]]]]);
* // => [1, 2, 3, [[4]]];
* _.flatten([1, [2, 3, [4]]]);
* // => [1, 2, 3, [4]]
*
* // using `isDeep`
* _.flatten([1, [2], [3, [[4]]]], true);
* // => [1, 2, 3, 4];
* _.flatten([1, [2, 3, [4]]], true);
* // => [1, 2, 3, 4]
*/
function flatten(array, isDeep, guard) {
var length = array ? array.length : 0;

View File

@@ -10,8 +10,8 @@ define(['../internal/baseFlatten'], function(baseFlatten) {
* @returns {Array} Returns the new flattened array.
* @example
*
* _.flattenDeep([1, [2], [3, [[4]]]]);
* // => [1, 2, 3, 4];
* _.flattenDeep([1, [2, 3, [4]]]);
* // => [1, 2, 3, 4]
*/
function flattenDeep(array) {
var length = array ? array.length : 0;

View File

@@ -9,10 +9,9 @@ define(['../internal/baseIndexOf', '../internal/binaryIndex'], function(baseInde
* it is used as the offset from the end of `array`. If `array` is sorted
* providing `true` for `fromIndex` performs a faster binary search.
*
* **Note:** `SameValueZero` comparisons are like strict equality comparisons,
* e.g. `===`, except that `NaN` matches `NaN`. See the
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* for more details.
* **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
* @memberOf _
@@ -24,15 +23,15 @@ define(['../internal/baseIndexOf', '../internal/binaryIndex'], function(baseInde
* @returns {number} Returns the index of the matched value, else `-1`.
* @example
*
* _.indexOf([1, 2, 3, 1, 2, 3], 2);
* _.indexOf([1, 2, 1, 2], 2);
* // => 1
*
* // using `fromIndex`
* _.indexOf([1, 2, 3, 1, 2, 3], 2, 3);
* // => 4
* _.indexOf([1, 2, 1, 2], 2, 2);
* // => 3
*
* // performing a binary search
* _.indexOf([4, 4, 5, 5, 6, 6], 5, true);
* _.indexOf([1, 1, 2, 2], 2, true);
* // => 2
*/
function indexOf(array, value, fromIndex) {
@@ -41,14 +40,17 @@ define(['../internal/baseIndexOf', '../internal/binaryIndex'], function(baseInde
return -1;
}
if (typeof fromIndex == 'number') {
fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : fromIndex;
} else if (fromIndex) {
var index = binaryIndex(array, value),
other = array[index];
return (value === value ? value === other : other !== other) ? index : -1;
if (value === value ? (value === other) : (other !== other)) {
return index;
}
return -1;
}
return baseIndexOf(array, value, fromIndex);
return baseIndexOf(array, value, fromIndex || 0);
}
return indexOf;

View File

@@ -4,10 +4,9 @@ define(['../internal/baseIndexOf', '../internal/cacheIndexOf', '../internal/crea
* Creates an array of unique values in all provided arrays using `SameValueZero`
* for equality comparisons.
*
* **Note:** `SameValueZero` comparisons are like strict equality comparisons,
* e.g. `===`, except that `NaN` matches `NaN`. See the
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* for more details.
* **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
* @memberOf _
@@ -15,9 +14,8 @@ define(['../internal/baseIndexOf', '../internal/cacheIndexOf', '../internal/crea
* @param {...Array} [arrays] The arrays to inspect.
* @returns {Array} Returns the new array of shared values.
* @example
*
* _.intersection([1, 2, 3], [5, 2, 1, 4], [2, 1]);
* // => [1, 2]
* _.intersection([1, 2], [4, 2], [2, 1]);
* // => [2]
*/
function intersection() {
var args = [],
@@ -31,7 +29,7 @@ define(['../internal/baseIndexOf', '../internal/cacheIndexOf', '../internal/crea
var value = arguments[argsIndex];
if (isArray(value) || isArguments(value)) {
args.push(value);
caches.push(isCommon && value.length >= 120 && createCache(argsIndex && value));
caches.push((isCommon && value.length >= 120) ? createCache(argsIndex && value) : null);
}
}
argsLength = args.length;
@@ -44,11 +42,11 @@ define(['../internal/baseIndexOf', '../internal/cacheIndexOf', '../internal/crea
outer:
while (++index < length) {
value = array[index];
if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value)) < 0) {
if ((seen ? cacheIndexOf(seen, value) : indexOf(result, value, 0)) < 0) {
argsIndex = argsLength;
while (--argsIndex) {
var cache = caches[argsIndex];
if ((cache ? cacheIndexOf(cache, value) : indexOf(args[argsIndex], value)) < 0) {
if ((cache ? cacheIndexOf(cache, value) : indexOf(args[argsIndex], value, 0)) < 0) {
continue outer;
}
}

View File

@@ -18,15 +18,15 @@ define(['../internal/binaryIndex', '../internal/indexOfNaN'], function(binaryInd
* @returns {number} Returns the index of the matched value, else `-1`.
* @example
*
* _.lastIndexOf([1, 2, 3, 1, 2, 3], 2);
* // => 4
* _.lastIndexOf([1, 2, 1, 2], 2);
* // => 3
*
* // using `fromIndex`
* _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3);
* _.lastIndexOf([1, 2, 1, 2], 2, 2);
* // => 1
*
* // performing a binary search
* _.lastIndexOf([4, 4, 5, 5, 6, 6], 5, true);
* _.lastIndexOf([1, 1, 2, 2], 2, true);
* // => 3
*/
function lastIndexOf(array, value, fromIndex) {
@@ -40,7 +40,10 @@ define(['../internal/binaryIndex', '../internal/indexOfNaN'], function(binaryInd
} else if (fromIndex) {
index = binaryIndex(array, value, true) - 1;
var other = array[index];
return (value === value ? value === other : other !== other) ? index : -1;
if (value === value ? (value === other) : (other !== other)) {
return index;
}
return -1;
}
if (value !== value) {
return indexOfNaN(array, index, true);

View File

@@ -11,10 +11,10 @@ define(['../internal/baseIndexOf'], function(baseIndexOf) {
* comparisons.
*
* **Notes:**
* - Unlike `_.without`, this method mutates `array`.
* - `SameValueZero` comparisons are like strict equality comparisons, e.g. `===`,
* except that `NaN` matches `NaN`. See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* for more details.
* - 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
* @memberOf _
@@ -25,22 +25,25 @@ define(['../internal/baseIndexOf'], function(baseIndexOf) {
* @example
*
* var array = [1, 2, 3, 1, 2, 3];
*
* _.pull(array, 2, 3);
* console.log(array);
* // => [1, 1]
*/
function pull() {
var array = arguments[0];
var args = arguments,
array = args[0];
if (!(array && array.length)) {
return array;
}
var index = 0,
indexOf = baseIndexOf,
length = arguments.length;
length = args.length;
while (++index < length) {
var fromIndex = 0,
value = arguments[index];
value = args[index];
while ((fromIndex = indexOf(array, value, fromIndex)) > -1) {
splice.call(array, fromIndex, 1);

View File

@@ -1,4 +1,10 @@
define(['../internal/baseFlatten', '../internal/basePullAt'], function(baseFlatten, basePullAt) {
define(['../internal/baseAt', '../internal/baseCompareAscending', '../internal/baseFlatten', '../internal/isIndex', '../function/restParam'], function(baseAt, baseCompareAscending, baseFlatten, isIndex, restParam) {
/** Used for native method references. */
var arrayProto = Array.prototype;
/** Native method references. */
var splice = arrayProto.splice;
/**
* Removes elements from `array` corresponding to the given indexes and returns
@@ -17,7 +23,7 @@ define(['../internal/baseFlatten', '../internal/basePullAt'], function(baseFlatt
* @example
*
* var array = [5, 10, 15, 20];
* var evens = _.pullAt(array, [1, 3]);
* var evens = _.pullAt(array, 1, 3);
*
* console.log(array);
* // => [5, 15]
@@ -25,9 +31,23 @@ define(['../internal/baseFlatten', '../internal/basePullAt'], function(baseFlatt
* console.log(evens);
* // => [10, 20]
*/
function pullAt(array) {
return basePullAt(array || [], baseFlatten(arguments, false, false, 1));
}
var pullAt = restParam(function(array, indexes) {
array || (array = []);
indexes = baseFlatten(indexes);
var length = indexes.length,
result = baseAt(array, indexes);
indexes.sort(baseCompareAscending);
while (length--) {
var index = parseFloat(indexes[length]);
if (index != previous && isIndex(index)) {
var previous = index;
splice.call(array, index, 1);
}
}
return result;
});
return pullAt;
});

View File

@@ -9,12 +9,16 @@ define(['../internal/baseCallback'], function(baseCallback) {
/**
* Removes all elements from `array` that `predicate` returns truthy for
* and returns an array of the removed elements. The predicate is bound to
* `thisArg` and invoked with three arguments; (value, index, array).
* `thisArg` and invoked with three arguments: (value, index, array).
*
* If a property name is provided for `predicate` the created "_.property"
* If a property name is provided for `predicate` the created `_.property`
* style callback returns the property value of the given element.
*
* If an object is provided for `predicate` the created "_.matches" style
* 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`.
*
@@ -25,14 +29,15 @@ define(['../internal/baseCallback'], function(baseCallback) {
* @category Array
* @param {Array} array The array to modify.
* @param {Function|Object|string} [predicate=_.identity] The function invoked
* per iteration. If a property name or object is provided it is used to
* create a "_.property" or "_.matches" style callback respectively.
* per iteration.
* @param {*} [thisArg] The `this` binding of `predicate`.
* @returns {Array} Returns the new array of removed elements.
* @example
*
* var array = [1, 2, 3, 4];
* var evens = _.remove(array, function(n) { return n % 2 == 0; });
* var evens = _.remove(array, function(n) {
* return n % 2 == 0;
* });
*
* console.log(array);
* // => [1, 3]

View File

@@ -1,4 +1,4 @@
define(['../internal/baseCallback', '../internal/binaryIndex', '../internal/binaryIndexBy'], function(baseCallback, binaryIndex, binaryIndexBy) {
define(['../internal/createSortedIndex'], function(createSortedIndex) {
/**
* Uses a binary search to determine the lowest index at which `value` should
@@ -7,10 +7,14 @@ define(['../internal/baseCallback', '../internal/binaryIndex', '../internal/bina
* to compute their sort ranking. The iteratee is bound to `thisArg` and
* invoked with one argument; (value).
*
* If a property name is provided for `predicate` the created "_.property"
* If a property name is provided for `iteratee` the created `_.property`
* style callback returns the property value of the given element.
*
* If an object is provided for `predicate` the created "_.matches" style
* 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 `iteratee` the created `_.matches` style
* callback returns `true` for elements that have the properties of the given
* object, else `false`.
*
@@ -20,8 +24,7 @@ define(['../internal/baseCallback', '../internal/binaryIndex', '../internal/bina
* @param {Array} array The sorted array to inspect.
* @param {*} value The value to evaluate.
* @param {Function|Object|string} [iteratee=_.identity] The function invoked
* per iteration. If a property name or object is provided it is used to
* create a "_.property" or "_.matches" style callback respectively.
* per iteration.
* @param {*} [thisArg] The `this` binding of `iteratee`.
* @returns {number} Returns the index at which `value` should be inserted
* into `array`.
@@ -30,7 +33,7 @@ define(['../internal/baseCallback', '../internal/binaryIndex', '../internal/bina
* _.sortedIndex([30, 50], 40);
* // => 1
*
* _.sortedIndex([4, 4, 5, 5, 6, 6], 5);
* _.sortedIndex([4, 4, 5, 5], 5);
* // => 2
*
* var dict = { 'data': { 'thirty': 30, 'forty': 40, 'fifty': 50 } };
@@ -41,15 +44,11 @@ define(['../internal/baseCallback', '../internal/binaryIndex', '../internal/bina
* }, dict);
* // => 1
*
* // using the "_.property" callback shorthand
* // using the `_.property` callback shorthand
* _.sortedIndex([{ 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x');
* // => 1
*/
function sortedIndex(array, value, iteratee, thisArg) {
return iteratee == null
? binaryIndex(array, value)
: binaryIndexBy(array, value, baseCallback(iteratee, thisArg, 1));
}
var sortedIndex = createSortedIndex();
return sortedIndex;
});

View File

@@ -1,4 +1,4 @@
define(['../internal/baseCallback', '../internal/binaryIndex', '../internal/binaryIndexBy'], function(baseCallback, binaryIndex, binaryIndexBy) {
define(['../internal/createSortedIndex'], function(createSortedIndex) {
/**
* This method is like `_.sortedIndex` except that it returns the highest
@@ -11,21 +11,16 @@ define(['../internal/baseCallback', '../internal/binaryIndex', '../internal/bina
* @param {Array} array The sorted array to inspect.
* @param {*} value The value to evaluate.
* @param {Function|Object|string} [iteratee=_.identity] The function invoked
* per iteration. If a property name or object is provided it is used to
* create a "_.property" or "_.matches" style callback respectively.
* per iteration.
* @param {*} [thisArg] The `this` binding of `iteratee`.
* @returns {number} Returns the index at which `value` should be inserted
* into `array`.
* @example
*
* _.sortedLastIndex([4, 4, 5, 5, 6, 6], 5);
* _.sortedLastIndex([4, 4, 5, 5], 5);
* // => 4
*/
function sortedLastIndex(array, value, iteratee, thisArg) {
return iteratee == null
? binaryIndex(array, value, true)
: binaryIndexBy(array, value, baseCallback(iteratee, thisArg, 1), true);
}
var sortedLastIndex = createSortedIndex(true);
return sortedLastIndex;
});

View File

@@ -5,7 +5,6 @@ define(['../internal/baseSlice', '../internal/isIterateeCall'], function(baseSli
*
* @static
* @memberOf _
* @type Function
* @category Array
* @param {Array} array The array to query.
* @param {number} [n=1] The number of elements to take.

View File

@@ -5,7 +5,6 @@ define(['../internal/baseSlice', '../internal/isIterateeCall'], function(baseSli
*
* @static
* @memberOf _
* @type Function
* @category Array
* @param {Array} array The array to query.
* @param {number} [n=1] The number of elements to take.

View File

@@ -1,53 +1,58 @@
define(['../internal/baseCallback', '../internal/baseSlice'], function(baseCallback, baseSlice) {
define(['../internal/baseCallback', '../internal/baseWhile'], function(baseCallback, baseWhile) {
/**
* Creates a slice of `array` with elements taken from the end. Elements are
* taken until `predicate` returns falsey. The predicate is bound to `thisArg`
* and invoked with three arguments; (value, index, array).
* and invoked with three arguments: (value, index, array).
*
* If a property name is provided for `predicate` the created "_.property"
* If a property name is provided for `predicate` the created `_.property`
* style callback returns the property value of the given element.
*
* If an object is provided for `predicate` the created "_.matches" style
* 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
* @memberOf _
* @type Function
* @category Array
* @param {Array} array The array to query.
* @param {Function|Object|string} [predicate=_.identity] The function invoked
* per element.
* per iteration.
* @param {*} [thisArg] The `this` binding of `predicate`.
* @returns {Array} Returns the slice of `array`.
* @example
*
* _.takeRightWhile([1, 2, 3], function(n) { return n > 1; });
* _.takeRightWhile([1, 2, 3], function(n) {
* return n > 1;
* });
* // => [2, 3]
*
* var users = [
* { 'user': 'barney', 'status': 'busy', 'active': false },
* { 'user': 'fred', 'status': 'busy', 'active': true },
* { 'user': 'pebbles', 'status': 'away', 'active': true }
* { 'user': 'barney', 'active': true },
* { 'user': 'fred', 'active': false },
* { 'user': 'pebbles', 'active': false }
* ];
*
* // using the "_.property" callback shorthand
* _.pluck(_.takeRightWhile(users, 'active'), 'user');
* // using the `_.matches` callback shorthand
* _.pluck(_.takeRightWhile(users, { 'user': 'pebbles', 'active': false }), 'user');
* // => ['pebbles']
*
* // using the `_.matchesProperty` callback shorthand
* _.pluck(_.takeRightWhile(users, 'active', false), 'user');
* // => ['fred', 'pebbles']
*
* // using the "_.matches" callback shorthand
* _.pluck(_.takeRightWhile(users, { 'status': 'away' }), 'user');
* // => ['pebbles']
* // using the `_.property` callback shorthand
* _.pluck(_.takeRightWhile(users, 'active'), 'user');
* // => []
*/
function takeRightWhile(array, predicate, thisArg) {
var length = array ? array.length : 0;
if (!length) {
return [];
}
predicate = baseCallback(predicate, thisArg, 3);
while (length-- && predicate(array[length], length, array)) {}
return baseSlice(array, length + 1);
return (array && array.length)
? baseWhile(array, baseCallback(predicate, thisArg, 3), false, true)
: [];
}
return takeRightWhile;

View File

@@ -1,54 +1,58 @@
define(['../internal/baseCallback', '../internal/baseSlice'], function(baseCallback, baseSlice) {
define(['../internal/baseCallback', '../internal/baseWhile'], function(baseCallback, baseWhile) {
/**
* Creates a slice of `array` with elements taken from the beginning. Elements
* are taken until `predicate` returns falsey. The predicate is bound to
* `thisArg` and invoked with three arguments; (value, index, array).
* `thisArg` and invoked with three arguments: (value, index, array).
*
* If a property name is provided for `predicate` the created "_.property"
* If a property name is provided for `predicate` the created `_.property`
* style callback returns the property value of the given element.
*
* If an object is provided for `predicate` the created "_.matches" style
* 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
* @memberOf _
* @type Function
* @category Array
* @param {Array} array The array to query.
* @param {Function|Object|string} [predicate=_.identity] The function invoked
* per element.
* per iteration.
* @param {*} [thisArg] The `this` binding of `predicate`.
* @returns {Array} Returns the slice of `array`.
* @example
*
* _.takeWhile([1, 2, 3], function(n) { return n < 3; });
* _.takeWhile([1, 2, 3], function(n) {
* return n < 3;
* });
* // => [1, 2]
*
* var users = [
* { 'user': 'barney', 'status': 'busy', 'active': true },
* { 'user': 'fred', 'status': 'busy', 'active': false },
* { 'user': 'pebbles', 'status': 'away', 'active': true }
* { 'user': 'barney', 'active': false },
* { 'user': 'fred', 'active': false},
* { 'user': 'pebbles', 'active': true }
* ];
*
* // using the "_.property" callback shorthand
* _.pluck(_.takeWhile(users, 'active'), 'user');
* // using the `_.matches` callback shorthand
* _.pluck(_.takeWhile(users, { 'user': 'barney', 'active': false }), 'user');
* // => ['barney']
*
* // using the "_.matches" callback shorthand
* _.pluck(_.takeWhile(users, { 'status': 'busy' }), 'user');
* // using the `_.matchesProperty` callback shorthand
* _.pluck(_.takeWhile(users, 'active', false), 'user');
* // => ['barney', 'fred']
*
* // using the `_.property` callback shorthand
* _.pluck(_.takeWhile(users, 'active'), 'user');
* // => []
*/
function takeWhile(array, predicate, thisArg) {
var length = array ? array.length : 0;
if (!length) {
return [];
}
var index = -1;
predicate = baseCallback(predicate, thisArg, 3);
while (++index < length && predicate(array[index], index, array)) {}
return baseSlice(array, 0, index);
return (array && array.length)
? baseWhile(array, baseCallback(predicate, thisArg, 3))
: [];
}
return takeWhile;

View File

@@ -1,13 +1,12 @@
define(['../internal/baseFlatten', '../internal/baseUniq'], function(baseFlatten, baseUniq) {
define(['../internal/baseFlatten', '../internal/baseUniq', '../function/restParam'], function(baseFlatten, baseUniq, restParam) {
/**
* Creates an array of unique values, in order, of the provided arrays using
* `SameValueZero` for equality comparisons.
*
* **Note:** `SameValueZero` comparisons are like strict equality comparisons,
* e.g. `===`, except that `NaN` matches `NaN`. See the
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* for more details.
* **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
* @memberOf _
@@ -16,12 +15,12 @@ define(['../internal/baseFlatten', '../internal/baseUniq'], function(baseFlatten
* @returns {Array} Returns the new array of combined values.
* @example
*
* _.union([1, 2, 3], [5, 2, 1, 4], [2, 1]);
* // => [1, 2, 3, 5, 4]
* _.union([1, 2], [4, 2], [2, 1]);
* // => [1, 2, 4]
*/
function union() {
return baseUniq(baseFlatten(arguments, false, true));
}
var union = restParam(function(arrays) {
return baseUniq(baseFlatten(arrays, false, true));
});
return union;
});

View File

@@ -6,19 +6,22 @@ define(['../internal/baseCallback', '../internal/baseUniq', '../internal/isItera
* search algorithm for sorted arrays. If an iteratee function is provided it
* is invoked for each value in the array to generate the criterion by which
* uniqueness is computed. The `iteratee` is bound to `thisArg` and invoked
* with three arguments; (value, index, array).
* with three arguments: (value, index, array).
*
* If a property name is provided for `predicate` the created "_.property"
* If a property name is provided for `iteratee` the created `_.property`
* style callback returns the property value of the given element.
*
* If an object is provided for `predicate` the created "_.matches" style
* 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 `iteratee` the created `_.matches` style
* callback returns `true` for elements that have the properties of the given
* object, else `false`.
*
* **Note:** `SameValueZero` comparisons are like strict equality comparisons,
* e.g. `===`, except that `NaN` matches `NaN`. See the
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* for more details.
* **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
* @memberOf _
@@ -27,8 +30,6 @@ define(['../internal/baseCallback', '../internal/baseUniq', '../internal/isItera
* @param {Array} array The array to inspect.
* @param {boolean} [isSorted] Specify the array is sorted.
* @param {Function|Object|string} [iteratee] The function invoked per iteration.
* If a property name or object is provided it is used to create a "_.property"
* or "_.matches" style callback respectively.
* @param {*} [thisArg] The `this` binding of `iteratee`.
* @returns {Array} Returns the new duplicate-value-free array.
* @example
@@ -41,10 +42,12 @@ define(['../internal/baseCallback', '../internal/baseUniq', '../internal/isItera
* // => [1, 2]
*
* // using an iteratee function
* _.uniq([1, 2.5, 1.5, 2], function(n) { return this.floor(n); }, Math);
* _.uniq([1, 2.5, 1.5, 2], function(n) {
* return this.floor(n);
* }, Math);
* // => [1, 2.5]
*
* // using the "_.property" callback shorthand
* // using the `_.property` callback shorthand
* _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 1 }, { 'x': 2 }]
*/
@@ -53,8 +56,7 @@ define(['../internal/baseCallback', '../internal/baseUniq', '../internal/isItera
if (!length) {
return [];
}
// Juggle arguments.
if (typeof isSorted != 'boolean' && isSorted != null) {
if (isSorted != null && typeof isSorted != 'boolean') {
thisArg = iteratee;
iteratee = isIterateeCall(array, isSorted, thisArg) ? null : isSorted;
isSorted = false;

View File

@@ -1,13 +1,12 @@
define(['../internal/baseDifference', '../internal/baseSlice'], function(baseDifference, baseSlice) {
define(['../internal/baseDifference', '../lang/isArguments', '../lang/isArray', '../function/restParam'], function(baseDifference, isArguments, isArray, restParam) {
/**
* Creates an array excluding all provided values using `SameValueZero` for
* equality comparisons.
*
* **Note:** `SameValueZero` comparisons are like strict equality comparisons,
* e.g. `===`, except that `NaN` matches `NaN`. See the
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* for more details.
* **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
* @memberOf _
@@ -17,12 +16,14 @@ define(['../internal/baseDifference', '../internal/baseSlice'], function(baseDif
* @returns {Array} Returns the new array of filtered values.
* @example
*
* _.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
* // => [2, 3, 4]
* _.without([1, 2, 1, 3], 1, 2);
* // => [3]
*/
function without(array) {
return baseDifference(array, baseSlice(arguments, 1));
}
var without = restParam(function(array, values) {
return (isArray(array) || isArguments(array))
? baseDifference(array, values)
: [];
});
return without;
});

View File

@@ -1,9 +1,8 @@
define(['../internal/baseDifference', '../internal/baseUniq', '../lang/isArguments', '../lang/isArray'], function(baseDifference, baseUniq, isArguments, isArray) {
/**
* Creates an array that is the symmetric difference of the provided arrays.
* See [Wikipedia](https://en.wikipedia.org/wiki/Symmetric_difference) for
* more details.
* Creates an array that is the [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference)
* of the provided arrays.
*
* @static
* @memberOf _
@@ -12,11 +11,8 @@ define(['../internal/baseDifference', '../internal/baseUniq', '../lang/isArgumen
* @returns {Array} Returns the new array of values.
* @example
*
* _.xor([1, 2, 3], [5, 2, 1, 4]);
* // => [3, 5, 4]
*
* _.xor([1, 2, 5], [2, 3, 5], [3, 4, 5]);
* // => [1, 4, 5]
* _.xor([1, 2], [4, 2]);
* // => [1, 4]
*/
function xor() {
var index = -1,

View File

@@ -1,4 +1,4 @@
define(['./unzip'], function(unzip) {
define(['../function/restParam', './unzip'], function(restParam, unzip) {
/**
* Creates an array of grouped elements, the first of which contains the first
@@ -15,15 +15,7 @@ define(['./unzip'], function(unzip) {
* _.zip(['fred', 'barney'], [30, 40], [true, false]);
* // => [['fred', 30, true], ['barney', 40, false]]
*/
function zip() {
var length = arguments.length,
array = Array(length);
while (length--) {
array[length] = arguments[length];
}
return unzip(array);
}
var zip = restParam(unzip);
return zip;
});

View File

@@ -1,9 +1,10 @@
define(['../lang/isArray'], function(isArray) {
/**
* Creates an object composed from arrays of property names and values. Provide
* either a single two dimensional array, e.g. `[[key1, value1], [key2, value2]]`
* or two arrays, one of property names and one of corresponding values.
* The inverse of `_.pairs`; this method returns an object composed from arrays
* of property names and values. Provide either a single two dimensional array,
* e.g. `[[key1, value1], [key2, value2]]` or two arrays, one of property names
* and one of corresponding values.
*
* @static
* @memberOf _
@@ -14,6 +15,9 @@ define(['../lang/isArray'], function(isArray) {
* @returns {Object} Returns the new object.
* @example
*
* _.zipObject([['fred', 30], ['barney', 40]]);
* // => { 'fred': 30, 'barney': 40 }
*
* _.zipObject(['fred', 'barney'], [30, 40]);
* // => { 'fred': 30, 'barney': 40 }
*/

View File

@@ -1,8 +1,11 @@
define(['./chain/chain', './chain/lodash', './chain/reverse', './chain/tap', './chain/thru', './chain/toJSON', './chain/toString', './chain/value', './chain/valueOf', './chain/wrapperChain'], function(chain, lodash, reverse, tap, thru, toJSON, toString, value, valueOf, wrapperChain) {
define(['./chain/chain', './chain/commit', './chain/lodash', './chain/plant', './chain/reverse', './chain/run', './chain/tap', './chain/thru', './chain/toJSON', './chain/toString', './chain/value', './chain/valueOf', './chain/wrapperChain'], function(chain, commit, lodash, plant, reverse, run, tap, thru, toJSON, toString, value, valueOf, wrapperChain) {
return {
'chain': chain,
'commit': commit,
'lodash': lodash,
'plant': plant,
'reverse': reverse,
'run': run,
'tap': tap,
'thru': thru,
'toJSON': toJSON,

View File

@@ -8,7 +8,7 @@ define(['./lodash'], function(lodash) {
* @memberOf _
* @category Chain
* @param {*} value The value to wrap.
* @returns {Object} Returns the new `lodash` object.
* @returns {Object} Returns the new `lodash` wrapper instance.
* @example
*
* var users = [
@@ -19,7 +19,9 @@ define(['./lodash'], function(lodash) {
*
* var youngest = _.chain(users)
* .sortBy('age')
* .map(function(chr) { return chr.user + ' is ' + chr.age; })
* .map(function(chr) {
* return chr.user + ' is ' + chr.age;
* })
* .first()
* .value();
* // => 'pebbles is 1'

3
chain/commit.js Normal file
View File

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

View File

@@ -1,4 +1,4 @@
define(['../internal/LodashWrapper', '../internal/arrayCopy', '../lang/isArray', '../internal/isObjectLike'], function(LodashWrapper, arrayCopy, isArray, isObjectLike) {
define(['../internal/LazyWrapper', '../internal/LodashWrapper', '../internal/baseLodash', '../lang/isArray', '../internal/isObjectLike', '../internal/wrapperClone'], function(LazyWrapper, LodashWrapper, baseLodash, isArray, isObjectLike, wrapperClone) {
/** Used for native method references. */
var objectProto = Object.prototype;
@@ -7,7 +7,7 @@ define(['../internal/LodashWrapper', '../internal/arrayCopy', '../lang/isArray',
var hasOwnProperty = objectProto.hasOwnProperty;
/**
* Creates a `lodash` object which wraps `value` to enable intuitive chaining.
* Creates a `lodash` object which wraps `value` to enable implicit chaining.
* Methods that operate on and return arrays, collections, and functions can
* be chained together. Methods that return a boolean or single value will
* automatically end the chain returning the unwrapped value. Explicit chaining
@@ -22,65 +22,76 @@ define(['../internal/LodashWrapper', '../internal/arrayCopy', '../lang/isArray',
* Chaining is supported in custom builds as long as the `_#value` method is
* directly or indirectly included in the build.
*
* In addition to lodash methods, wrappers also have the following `Array` methods:
* `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`,
* and `unshift`
* In addition to lodash methods, wrappers have `Array` and `String` methods.
*
* The wrapper functions that support shortcut fusion are:
* `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`, `first`,
* `initial`, `last`, `map`, `pluck`, `reject`, `rest`, `reverse`, `slice`,
* `take`, `takeRight`, `takeRightWhile`, `takeWhile`, and `where`
* The wrapper `Array` methods are:
* `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`,
* `splice`, and `unshift`
*
* The chainable wrapper functions are:
* The wrapper `String` methods are:
* `replace` and `split`
*
* The wrapper methods that support shortcut fusion are:
* `compact`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`,
* `first`, `initial`, `last`, `map`, `pluck`, `reject`, `rest`, `reverse`,
* `slice`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `toArray`,
* and `where`
*
* The chainable wrapper methods are:
* `after`, `ary`, `assign`, `at`, `before`, `bind`, `bindAll`, `bindKey`,
* `callback`, `chain`, `chunk`, `compact`, `concat`, `constant`, `countBy`,
* `create`, `curry`, `debounce`, `defaults`, `defer`, `delay`, `difference`,
* `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`, `flatten`,
* `flattenDeep`, `flow`, `flowRight`, `forEach`, `forEachRight`, `forIn`,
* `forInRight`, `forOwn`, `forOwnRight`, `functions`, `groupBy`, `indexBy`,
* `initial`, `intersection`, `invert`, `invoke`, `keys`, `keysIn`, `map`,
* `mapValues`, `matches`, `memoize`, `merge`, `mixin`, `negate`, `noop`,
* `omit`, `once`, `pairs`, `partial`, `partialRight`, `partition`, `pick`,
* `pluck`, `property`, `propertyOf`, `pull`, `pullAt`, `push`, `range`,
* `rearg`, `reject`, `remove`, `rest`, `reverse`, `shuffle`, `slice`, `sort`,
* `sortBy`, `sortByAll`, `splice`, `take`, `takeRight`, `takeRightWhile`,
* `takeWhile`, `tap`, `throttle`, `thru`, `times`, `toArray`, `toPlainObject`,
* `transform`, `union`, `uniq`, `unshift`, `unzip`, `values`, `valuesIn`,
* `where`, `without`, `wrap`, `xor`, `zip`, and `zipObject`
* `callback`, `chain`, `chunk`, `commit`, `compact`, `concat`, `constant`,
* `countBy`, `create`, `curry`, `debounce`, `defaults`, `defer`, `delay`,
* `difference`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `fill`,
* `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`, `forEach`,
* `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `functions`,
* `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`,
* `keysIn`, `map`, `mapValues`, `matches`, `matchesProperty`, `memoize`, `merge`,
* `mixin`, `negate`, `noop`, `omit`, `once`, `pairs`, `partial`, `partialRight`,
* `partition`, `pick`, `plant`, `pluck`, `property`, `propertyOf`, `pull`,
* `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `reverse`,
* `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`, `sortByOrder`, `splice`,
* `spread`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`,
* `throttle`, `thru`, `times`, `toArray`, `toPlainObject`, `transform`,
* `union`, `uniq`, `unshift`, `unzip`, `values`, `valuesIn`, `where`,
* `without`, `wrap`, `xor`, `zip`, and `zipObject`
*
* The wrapper functions that are **not** chainable by default are:
* `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`,
* The wrapper methods that are **not** chainable by default are:
* `add`, `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`,
* `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`,
* `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `has`,
* `identity`, `includes`, `indexOf`, `isArguments`, `isArray`, `isBoolean`,
* `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`, `isFinite`,
* `isFunction`, `isMatch` , `isNative`, `isNaN`, `isNull`, `isNumber`,
* `identity`, `includes`, `indexOf`, `inRange`, `isArguments`, `isArray`,
* `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`,
* `isFinite`,`isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`,
* `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`,
* `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `max`, `min`,
* `noConflict`, `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`,
* `random`, `reduce`, `reduceRight`, `repeat`, `result`, `runInContext`,
* `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`,
* `startsWith`, `template`, `trim`, `trimLeft`, `trimRight`, `trunc`,
* `unescape`, `uniqueId`, `value`, and `words`
* `startCase`, `startsWith`, `sum`, `template`, `trim`, `trimLeft`,
* `trimRight`, `trunc`, `unescape`, `uniqueId`, `value`, and `words`
*
* The wrapper function `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.
*
* @name _
* @constructor
* @category Chain
* @param {*} value The value to wrap in a `lodash` instance.
* @returns {Object} Returns a `lodash` instance.
* @returns {Object} Returns the new `lodash` wrapper instance.
* @example
*
* var wrapped = _([1, 2, 3]);
*
* // returns an unwrapped value
* wrapped.reduce(function(sum, n) { return sum + n; });
* wrapped.reduce(function(sum, n) {
* return sum + n;
* });
* // => 6
*
* // returns a wrapped value
* var squares = wrapped.map(function(n) { return n * n; });
* var squares = wrapped.map(function(n) {
* return n * n;
* });
*
* _.isArray(squares);
* // => false
@@ -89,19 +100,19 @@ define(['../internal/LodashWrapper', '../internal/arrayCopy', '../lang/isArray',
* // => true
*/
function lodash(value) {
if (isObjectLike(value) && !isArray(value)) {
if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
if (value instanceof LodashWrapper) {
return value;
}
if (hasOwnProperty.call(value, '__wrapped__')) {
return new LodashWrapper(value.__wrapped__, value.__chain__, arrayCopy(value.__actions__));
if (hasOwnProperty.call(value, '__chain__') && hasOwnProperty.call(value, '__wrapped__')) {
return wrapperClone(value);
}
}
return new LodashWrapper(value);
}
// Ensure `new LodashWrapper` is an instance of `lodash`.
LodashWrapper.prototype = lodash.prototype;
// Ensure wrappers are instances of `baseLodash`.
lodash.prototype = baseLodash.prototype;
return lodash;
});

3
chain/plant.js Normal file
View File

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

3
chain/run.js Normal file
View File

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

View File

@@ -16,7 +16,9 @@ define([], function() {
* @example
*
* _([1, 2, 3])
* .tap(function(array) { array.pop(); })
* .tap(function(array) {
* array.pop();
* })
* .reverse()
* .value();
* // => [2, 1]

View File

@@ -12,11 +12,14 @@ define([], function() {
* @returns {*} Returns the result of `interceptor`.
* @example
*
* _([1, 2, 3])
* .last()
* .thru(function(value) { return [value]; })
* _(' abc ')
* .chain()
* .trim()
* .thru(function(value) {
* return [value];
* })
* .value();
* // => [3]
* // => ['abc']
*/
function thru(value, interceptor, thisArg) {
return interceptor.call(thisArg, value);

View File

@@ -6,7 +6,7 @@ define(['./chain'], function(chain) {
* @name chain
* @memberOf _
* @category Chain
* @returns {*} Returns the `lodash` object.
* @returns {Object} Returns the new `lodash` wrapper instance.
* @example
*
* var users = [

33
chain/wrapperCommit.js Normal file
View File

@@ -0,0 +1,33 @@
define(['../internal/LodashWrapper'], function(LodashWrapper) {
/**
* Executes the chained sequence and returns the wrapped result.
*
* @name commit
* @memberOf _
* @category Chain
* @returns {Object} Returns the new `lodash` wrapper instance.
* @example
*
* var array = [1, 2];
* var wrapper = _(array).push(3);
*
* console.log(array);
* // => [1, 2]
*
* wrapper = wrapper.commit();
* console.log(array);
* // => [1, 2, 3]
*
* wrapper.last();
* // => 3
*
* console.log(array);
* // => [1, 2, 3]
*/
function wrapperCommit() {
return new LodashWrapper(this.value(), this.__chain__);
}
return wrapperCommit;
});

45
chain/wrapperPlant.js Normal file
View File

@@ -0,0 +1,45 @@
define(['../internal/baseLodash', '../internal/wrapperClone'], function(baseLodash, wrapperClone) {
/**
* Creates a clone of the chained sequence planting `value` as the wrapped value.
*
* @name plant
* @memberOf _
* @category Chain
* @returns {Object} Returns the new `lodash` wrapper instance.
* @example
*
* var array = [1, 2];
* var wrapper = _(array).map(function(value) {
* return Math.pow(value, 2);
* });
*
* var other = [3, 4];
* var otherWrapper = wrapper.plant(other);
*
* otherWrapper.value();
* // => [9, 16]
*
* wrapper.value();
* // => [1, 4]
*/
function wrapperPlant(value) {
var result,
parent = this;
while (parent instanceof baseLodash) {
var clone = wrapperClone(parent);
if (result) {
previous.__wrapped__ = clone;
} else {
result = clone;
}
var previous = clone;
parent = parent.__wrapped__;
}
previous.__wrapped__ = value;
return result;
}
return wrapperPlant;
});

View File

@@ -9,7 +9,7 @@ define(['../internal/LazyWrapper', '../internal/LodashWrapper', './thru'], funct
* @name reverse
* @memberOf _
* @category Chain
* @returns {Object} Returns the new reversed `lodash` object.
* @returns {Object} Returns the new reversed `lodash` wrapper instance.
* @example
*
* var array = [1, 2, 3];
@@ -23,7 +23,10 @@ define(['../internal/LazyWrapper', '../internal/LodashWrapper', './thru'], funct
function wrapperReverse() {
var value = this.__wrapped__;
if (value instanceof LazyWrapper) {
return new LodashWrapper(value.reverse());
if (this.__actions__.length) {
value = new LazyWrapper(this);
}
return new LodashWrapper(value.reverse(), this.__chain__);
}
return this.thru(function(value) {
return value.reverse();

View File

@@ -5,7 +5,7 @@ define(['../internal/baseWrapperValue'], function(baseWrapperValue) {
*
* @name value
* @memberOf _
* @alias toJSON, valueOf
* @alias run, toJSON, valueOf
* @category Chain
* @returns {*} Returns the resolved unwrapped value.
* @example

View File

@@ -1,4 +1,4 @@
define(['./collection/all', './collection/any', './collection/at', './collection/collect', './collection/contains', './collection/countBy', './collection/detect', './collection/each', './collection/eachRight', './collection/every', './collection/filter', './collection/find', './collection/findLast', './collection/findWhere', './collection/foldl', './collection/foldr', './collection/forEach', './collection/forEachRight', './collection/groupBy', './collection/include', './collection/includes', './collection/indexBy', './collection/inject', './collection/invoke', './collection/map', './collection/max', './collection/min', './collection/partition', './collection/pluck', './collection/reduce', './collection/reduceRight', './collection/reject', './collection/sample', './collection/select', './collection/shuffle', './collection/size', './collection/some', './collection/sortBy', './collection/sortByAll', './collection/where'], function(all, any, at, collect, contains, countBy, detect, each, eachRight, every, filter, find, findLast, findWhere, foldl, foldr, forEach, forEachRight, groupBy, include, includes, indexBy, inject, invoke, map, max, min, partition, pluck, reduce, reduceRight, reject, sample, select, shuffle, size, some, sortBy, sortByAll, where) {
define(['./collection/all', './collection/any', './collection/at', './collection/collect', './collection/contains', './collection/countBy', './collection/detect', './collection/each', './collection/eachRight', './collection/every', './collection/filter', './collection/find', './collection/findLast', './collection/findWhere', './collection/foldl', './collection/foldr', './collection/forEach', './collection/forEachRight', './collection/groupBy', './collection/include', './collection/includes', './collection/indexBy', './collection/inject', './collection/invoke', './collection/map', './math/max', './math/min', './collection/partition', './collection/pluck', './collection/reduce', './collection/reduceRight', './collection/reject', './collection/sample', './collection/select', './collection/shuffle', './collection/size', './collection/some', './collection/sortBy', './collection/sortByAll', './collection/sortByOrder', './math/sum', './collection/where'], function(all, any, at, collect, contains, countBy, detect, each, eachRight, every, filter, find, findLast, findWhere, foldl, foldr, forEach, forEachRight, groupBy, include, includes, indexBy, inject, invoke, map, max, min, partition, pluck, reduce, reduceRight, reject, sample, select, shuffle, size, some, sortBy, sortByAll, sortByOrder, sum, where) {
return {
'all': all,
'any': any,
@@ -39,6 +39,8 @@ define(['./collection/all', './collection/any', './collection/at', './collection
'some': some,
'sortBy': sortBy,
'sortByAll': sortByAll,
'sortByOrder': sortByOrder,
'sum': sum,
'where': where
};
});

View File

@@ -1,4 +1,4 @@
define(['../internal/baseAt', '../internal/baseFlatten', '../internal/isLength', '../internal/toIterable'], function(baseAt, baseFlatten, isLength, toIterable) {
define(['../internal/baseAt', '../internal/baseFlatten', '../internal/isLength', '../function/restParam', '../internal/toIterable'], function(baseAt, baseFlatten, isLength, restParam, toIterable) {
/**
* Creates an array of elements corresponding to the given keys, or indexes,
@@ -14,19 +14,19 @@ define(['../internal/baseAt', '../internal/baseFlatten', '../internal/isLength',
* @returns {Array} Returns the new array of picked elements.
* @example
*
* _.at(['a', 'b', 'c', 'd', 'e'], [0, 2, 4]);
* // => ['a', 'c', 'e']
* _.at(['a', 'b', 'c'], [0, 2]);
* // => ['a', 'c']
*
* _.at(['fred', 'barney', 'pebbles'], 0, 2);
* // => ['fred', 'pebbles']
* _.at(['barney', 'fred', 'pebbles'], 0, 2);
* // => ['barney', 'pebbles']
*/
function at(collection) {
var at = restParam(function(collection, props) {
var length = collection ? collection.length : 0;
if (isLength(length)) {
collection = toIterable(collection);
}
return baseAt(collection, baseFlatten(arguments, false, false, 1));
}
return baseAt(collection, baseFlatten(props));
});
return at;
});

View File

@@ -10,13 +10,17 @@ define(['../internal/createAggregator'], function(createAggregator) {
* Creates an object composed of keys generated from the results of running
* each element of `collection` through `iteratee`. The corresponding value
* of each key is the number of times the key was returned by `iteratee`.
* The `iteratee` is bound to `thisArg` and invoked with three arguments;
* The `iteratee` is bound to `thisArg` and invoked with three arguments:
* (value, index|key, collection).
*
* If a property name is provided for `predicate` the created "_.property"
* If a property name is provided for `iteratee` the created `_.property`
* style callback returns the property value of the given element.
*
* If an object is provided for `predicate` the created "_.matches" style
* 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 `iteratee` the created `_.matches` style
* callback returns `true` for elements that have the properties of the given
* object, else `false`.
*
@@ -25,16 +29,19 @@ define(['../internal/createAggregator'], function(createAggregator) {
* @category Collection
* @param {Array|Object|string} collection The collection to iterate over.
* @param {Function|Object|string} [iteratee=_.identity] The function invoked
* per iteration. If a property name or object is provided it is used to
* create a "_.property" or "_.matches" style callback respectively.
* per iteration.
* @param {*} [thisArg] The `this` binding of `iteratee`.
* @returns {Object} Returns the composed aggregate object.
* @example
*
* _.countBy([4.3, 6.1, 6.4], function(n) { return Math.floor(n); });
* _.countBy([4.3, 6.1, 6.4], function(n) {
* return Math.floor(n);
* });
* // => { '4': 1, '6': 2 }
*
* _.countBy([4.3, 6.1, 6.4], function(n) { return this.floor(n); }, Math);
* _.countBy([4.3, 6.1, 6.4], function(n) {
* return this.floor(n);
* }, Math);
* // => { '4': 1, '6': 2 }
*
* _.countBy(['one', 'two', 'three'], 'length');

View File

@@ -1,14 +1,18 @@
define(['../internal/arrayEvery', '../internal/baseCallback', '../internal/baseEvery', '../lang/isArray'], function(arrayEvery, baseCallback, baseEvery, isArray) {
define(['../internal/arrayEvery', '../internal/baseCallback', '../internal/baseEvery', '../lang/isArray', '../internal/isIterateeCall'], function(arrayEvery, baseCallback, baseEvery, isArray, isIterateeCall) {
/**
* Checks if `predicate` returns truthy for **all** elements of `collection`.
* The predicate is bound to `thisArg` and invoked with three arguments;
* The predicate is bound to `thisArg` and invoked with three arguments:
* (value, index|key, collection).
*
* If a property name is provided for `predicate` the created "_.property"
* If a property name is provided for `predicate` the created `_.property`
* style callback returns the property value of the given element.
*
* If an object is provided for `predicate` the created "_.matches" style
* 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`.
*
@@ -18,31 +22,37 @@ define(['../internal/arrayEvery', '../internal/baseCallback', '../internal/baseE
* @category Collection
* @param {Array|Object|string} collection The collection to iterate over.
* @param {Function|Object|string} [predicate=_.identity] The function invoked
* per iteration. If a property name or object is provided it is used to
* create a "_.property" or "_.matches" style callback respectively.
* per iteration.
* @param {*} [thisArg] The `this` binding of `predicate`.
* @returns {boolean} Returns `true` if all elements pass the predicate check,
* else `false`.
* @example
*
* _.every([true, 1, null, 'yes']);
* _.every([true, 1, null, 'yes'], Boolean);
* // => false
*
* var users = [
* { 'user': 'barney', 'age': 36 },
* { 'user': 'fred', 'age': 40 }
* { 'user': 'barney', 'active': false },
* { 'user': 'fred', 'active': false }
* ];
*
* // using the "_.property" callback shorthand
* _.every(users, 'age');
* // using the `_.matches` callback shorthand
* _.every(users, { 'user': 'barney', 'active': false });
* // => false
*
* // using the `_.matchesProperty` callback shorthand
* _.every(users, 'active', false);
* // => true
*
* // using the "_.matches" callback shorthand
* _.every(users, { 'age': 36 });
* // using the `_.property` callback shorthand
* _.every(users, 'active');
* // => false
*/
function every(collection, predicate, thisArg) {
var func = isArray(collection) ? arrayEvery : baseEvery;
if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
predicate = null;
}
if (typeof predicate != 'function' || typeof thisArg != 'undefined') {
predicate = baseCallback(predicate, thisArg, 3);
}

View File

@@ -3,12 +3,16 @@ define(['../internal/arrayFilter', '../internal/baseCallback', '../internal/base
/**
* Iterates over elements of `collection`, returning an array of all elements
* `predicate` returns truthy for. The predicate is bound to `thisArg` and
* invoked with three arguments; (value, index|key, collection).
* invoked with three arguments: (value, index|key, collection).
*
* If a property name is provided for `predicate` the created "_.property"
* If a property name is provided for `predicate` the created `_.property`
* style callback returns the property value of the given element.
*
* If an object is provided for `predicate` the created "_.matches" style
* 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`.
*
@@ -18,26 +22,31 @@ define(['../internal/arrayFilter', '../internal/baseCallback', '../internal/base
* @category Collection
* @param {Array|Object|string} collection The collection to iterate over.
* @param {Function|Object|string} [predicate=_.identity] The function invoked
* per iteration. If a property name or object is provided it is used to
* create a "_.property" or "_.matches" style callback respectively.
* per iteration.
* @param {*} [thisArg] The `this` binding of `predicate`.
* @returns {Array} Returns the new filtered array.
* @example
*
* var evens = _.filter([1, 2, 3, 4], function(n) { return n % 2 == 0; });
* // => [2, 4]
* _.filter([4, 5, 6], function(n) {
* return n % 2 == 0;
* });
* // => [4, 6]
*
* var users = [
* { 'user': 'barney', 'age': 36, 'active': false },
* { 'user': 'fred', 'age': 40, 'active': true }
* { 'user': 'barney', 'age': 36, 'active': true },
* { 'user': 'fred', 'age': 40, 'active': false }
* ];
*
* // using the "_.property" callback shorthand
* _.pluck(_.filter(users, 'active'), 'user');
* // using the `_.matches` callback shorthand
* _.pluck(_.filter(users, { 'age': 36, 'active': true }), 'user');
* // => ['barney']
*
* // using the `_.matchesProperty` callback shorthand
* _.pluck(_.filter(users, 'active', false), 'user');
* // => ['fred']
*
* // using the "_.matches" callback shorthand
* _.pluck(_.filter(users, { 'age': 36 }), 'user');
* // using the `_.property` callback shorthand
* _.pluck(_.filter(users, 'active'), 'user');
* // => ['barney']
*/
function filter(collection, predicate, thisArg) {

View File

@@ -1,17 +1,18 @@
define(['../internal/baseCallback', '../internal/baseEach', '../internal/baseFind', '../array/findIndex', '../lang/isArray'], function(baseCallback, baseEach, baseFind, findIndex, isArray) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
define(['../internal/baseEach', '../internal/createFind'], function(baseEach, createFind) {
/**
* Iterates over elements of `collection`, returning the first element
* `predicate` returns truthy for. The predicate is bound to `thisArg` and
* invoked with three arguments; (value, index|key, collection).
* invoked with three arguments: (value, index|key, collection).
*
* If a property name is provided for `predicate` the created "_.property"
* If a property name is provided for `predicate` the created `_.property`
* style callback returns the property value of the given element.
*
* If an object is provided for `predicate` the created "_.matches" style
* 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`.
*
@@ -21,37 +22,35 @@ define(['../internal/baseCallback', '../internal/baseEach', '../internal/baseFin
* @category Collection
* @param {Array|Object|string} collection The collection to search.
* @param {Function|Object|string} [predicate=_.identity] The function invoked
* per iteration. If a property name or object is provided it is used to
* create a "_.property" or "_.matches" style callback respectively.
* per iteration.
* @param {*} [thisArg] The `this` binding of `predicate`.
* @returns {*} Returns the matched element, else `undefined`.
* @example
*
* var users = [
* { 'user': 'barney', 'age': 36, 'active': false },
* { 'user': 'fred', 'age': 40, 'active': true },
* { 'user': 'pebbles', 'age': 1, 'active': false }
* { 'user': 'barney', 'age': 36, 'active': true },
* { 'user': 'fred', 'age': 40, 'active': false },
* { 'user': 'pebbles', 'age': 1, 'active': true }
* ];
*
* _.result(_.find(users, function(chr) { return chr.age < 40; }), 'user');
* _.result(_.find(users, function(chr) {
* return chr.age < 40;
* }), 'user');
* // => 'barney'
*
* // using the "_.matches" callback shorthand
* _.result(_.find(users, { 'age': 1 }), 'user');
* // using the `_.matches` callback shorthand
* _.result(_.find(users, { 'age': 1, 'active': true }), 'user');
* // => 'pebbles'
*
* // using the "_.property" callback shorthand
* _.result(_.find(users, 'active'), 'user');
* // using the `_.matchesProperty` callback shorthand
* _.result(_.find(users, 'active', false), 'user');
* // => 'fred'
*
* // using the `_.property` callback shorthand
* _.result(_.find(users, 'active'), 'user');
* // => 'barney'
*/
function find(collection, predicate, thisArg) {
if (isArray(collection)) {
var index = findIndex(collection, predicate, thisArg);
return index > -1 ? collection[index] : undefined;
}
predicate = baseCallback(predicate, thisArg, 3);
return baseFind(collection, predicate, baseEach);
}
var find = createFind(baseEach);
return find;
});

View File

@@ -1,4 +1,4 @@
define(['../internal/baseCallback', '../internal/baseEachRight', '../internal/baseFind'], function(baseCallback, baseEachRight, baseFind) {
define(['../internal/baseEachRight', '../internal/createFind'], function(baseEachRight, createFind) {
/**
* This method is like `_.find` except that it iterates over elements of
@@ -9,19 +9,17 @@ define(['../internal/baseCallback', '../internal/baseEachRight', '../internal/ba
* @category Collection
* @param {Array|Object|string} collection The collection to search.
* @param {Function|Object|string} [predicate=_.identity] The function invoked
* per iteration. If a property name or object is provided it is used to
* create a "_.property" or "_.matches" style callback respectively.
* per iteration.
* @param {*} [thisArg] The `this` binding of `predicate`.
* @returns {*} Returns the matched element, else `undefined`.
* @example
*
* _.findLast([1, 2, 3, 4], function(n) { return n % 2 == 1; });
* _.findLast([1, 2, 3, 4], function(n) {
* return n % 2 == 1;
* });
* // => 3
*/
function findLast(collection, predicate, thisArg) {
predicate = baseCallback(predicate, thisArg, 3);
return baseFind(collection, predicate, baseEachRight);
}
var findLast = createFind(baseEachRight, true);
return findLast;
});

View File

@@ -1,10 +1,15 @@
define(['./find', '../utility/matches'], function(find, matches) {
define(['../internal/baseMatches', './find'], function(baseMatches, find) {
/**
* Performs a deep comparison between each element in `collection` and the
* source object, returning the first element that has equivalent property
* values.
*
* **Note:** This method supports comparing arrays, booleans, `Date` objects,
* numbers, `Object` objects, regexes, and strings. Objects are compared by
* their own, not inherited, enumerable properties. For comparing a single
* own or inherited property value see `_.matchesProperty`.
*
* @static
* @memberOf _
* @category Collection
@@ -14,18 +19,18 @@ define(['./find', '../utility/matches'], function(find, matches) {
* @example
*
* var users = [
* { 'user': 'barney', 'age': 36, 'status': 'busy' },
* { 'user': 'fred', 'age': 40, 'status': 'busy' }
* { 'user': 'barney', 'age': 36, 'active': true },
* { 'user': 'fred', 'age': 40, 'active': false }
* ];
*
* _.result(_.findWhere(users, { 'status': 'busy' }), 'user');
* _.result(_.findWhere(users, { 'age': 36, 'active': true }), 'user');
* // => 'barney'
*
* _.result(_.findWhere(users, { 'age': 40 }), 'user');
* _.result(_.findWhere(users, { 'age': 40, 'active': false }), 'user');
* // => 'fred'
*/
function findWhere(collection, source) {
return find(collection, matches(source));
return find(collection, baseMatches(source));
}
return findWhere;

View File

@@ -1,8 +1,8 @@
define(['../internal/arrayEach', '../internal/baseEach', '../internal/bindCallback', '../lang/isArray'], function(arrayEach, baseEach, bindCallback, isArray) {
define(['../internal/arrayEach', '../internal/baseEach', '../internal/createForEach'], function(arrayEach, baseEach, createForEach) {
/**
* Iterates over elements of `collection` invoking `iteratee` for each element.
* The `iteratee` is bound to `thisArg` and invoked with three arguments;
* The `iteratee` is bound to `thisArg` and invoked with three arguments:
* (value, index|key, collection). Iterator functions may exit iteration early
* by explicitly returning `false`.
*
@@ -20,17 +20,17 @@ define(['../internal/arrayEach', '../internal/baseEach', '../internal/bindCallba
* @returns {Array|Object|string} Returns `collection`.
* @example
*
* _([1, 2, 3]).forEach(function(n) { console.log(n); });
* _([1, 2]).forEach(function(n) {
* console.log(n);
* }).value();
* // => logs each value from left to right and returns the array
*
* _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(n, key) { console.log(n, key); });
* _.forEach({ 'a': 1, 'b': 2 }, function(n, key) {
* console.log(n, key);
* });
* // => logs each value-key pair and returns the object (iteration order is not guaranteed)
*/
function forEach(collection, iteratee, thisArg) {
return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection))
? arrayEach(collection, iteratee)
: baseEach(collection, bindCallback(iteratee, thisArg, 3));
}
var forEach = createForEach(arrayEach, baseEach);
return forEach;
});

View File

@@ -1,4 +1,4 @@
define(['../internal/arrayEachRight', '../internal/baseEachRight', '../internal/bindCallback', '../lang/isArray'], function(arrayEachRight, baseEachRight, bindCallback, isArray) {
define(['../internal/arrayEachRight', '../internal/baseEachRight', '../internal/createForEach'], function(arrayEachRight, baseEachRight, createForEach) {
/**
* This method is like `_.forEach` except that it iterates over elements of
@@ -14,14 +14,12 @@ define(['../internal/arrayEachRight', '../internal/baseEachRight', '../internal/
* @returns {Array|Object|string} Returns `collection`.
* @example
*
* _([1, 2, 3]).forEachRight(function(n) { console.log(n); }).join(',');
* _([1, 2]).forEachRight(function(n) {
* console.log(n);
* }).value();
* // => logs each value from right to left and returns the array
*/
function forEachRight(collection, iteratee, thisArg) {
return (typeof iteratee == 'function' && typeof thisArg == 'undefined' && isArray(collection))
? arrayEachRight(collection, iteratee)
: baseEachRight(collection, bindCallback(iteratee, thisArg, 3));
}
var forEachRight = createForEach(arrayEachRight, baseEachRight);
return forEachRight;
});

View File

@@ -10,13 +10,17 @@ define(['../internal/createAggregator'], function(createAggregator) {
* Creates an object composed of keys generated from the results of running
* each element of `collection` through `iteratee`. The corresponding value
* of each key is an array of the elements responsible for generating the key.
* The `iteratee` is bound to `thisArg` and invoked with three arguments;
* The `iteratee` is bound to `thisArg` and invoked with three arguments:
* (value, index|key, collection).
*
* If a property name is provided for `predicate` the created "_.property"
* If a property name is provided for `iteratee` the created `_.property`
* style callback returns the property value of the given element.
*
* If an object is provided for `predicate` the created "_.matches" style
* 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 `iteratee` the created `_.matches` style
* callback returns `true` for elements that have the properties of the given
* object, else `false`.
*
@@ -25,19 +29,22 @@ define(['../internal/createAggregator'], function(createAggregator) {
* @category Collection
* @param {Array|Object|string} collection The collection to iterate over.
* @param {Function|Object|string} [iteratee=_.identity] The function invoked
* per iteration. If a property name or object is provided it is used to
* create a "_.property" or "_.matches" style callback respectively.
* per iteration.
* @param {*} [thisArg] The `this` binding of `iteratee`.
* @returns {Object} Returns the composed aggregate object.
* @example
*
* _.groupBy([4.2, 6.1, 6.4], function(n) { return Math.floor(n); });
* _.groupBy([4.2, 6.1, 6.4], function(n) {
* return Math.floor(n);
* });
* // => { '4': [4.2], '6': [6.1, 6.4] }
*
* _.groupBy([4.2, 6.1, 6.4], function(n) { return this.floor(n); }, Math);
* _.groupBy([4.2, 6.1, 6.4], function(n) {
* return this.floor(n);
* }, Math);
* // => { '4': [4.2], '6': [6.1, 6.4] }
*
* // using the "_.property" callback shorthand
* // using the `_.property` callback shorthand
* _.groupBy(['one', 'two', 'three'], 'length');
* // => { '3': ['one', 'two'], '5': ['three'] }
*/

View File

@@ -1,4 +1,4 @@
define(['../internal/baseIndexOf', '../lang/isArray', '../internal/isLength', '../lang/isString', '../object/values'], function(baseIndexOf, isArray, isLength, isString, values) {
define(['../internal/baseIndexOf', '../lang/isArray', '../internal/isIterateeCall', '../internal/isLength', '../lang/isString', '../object/values'], function(baseIndexOf, isArray, isIterateeCall, isLength, isString, values) {
/* Native method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max;
@@ -8,10 +8,9 @@ define(['../internal/baseIndexOf', '../lang/isArray', '../internal/isLength', '.
* comparisons. If `fromIndex` is negative, it is used as the offset from
* the end of `collection`.
*
* **Note:** `SameValueZero` comparisons are like strict equality comparisons,
* e.g. `===`, except that `NaN` matches `NaN`. See the
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero)
* for more details.
* **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
* @memberOf _
@@ -20,6 +19,7 @@ define(['../internal/baseIndexOf', '../lang/isArray', '../internal/isLength', '.
* @param {Array|Object|string} collection The collection to search.
* @param {*} target The value to search for.
* @param {number} [fromIndex=0] The index to search from.
* @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`.
* @returns {boolean} Returns `true` if a matching element is found, else `false`.
* @example
*
@@ -35,7 +35,7 @@ define(['../internal/baseIndexOf', '../lang/isArray', '../internal/isLength', '.
* _.includes('pebbles', 'eb');
* // => true
*/
function includes(collection, target, fromIndex) {
function includes(collection, target, fromIndex, guard) {
var length = collection ? collection.length : 0;
if (!isLength(length)) {
collection = values(collection);
@@ -44,10 +44,10 @@ define(['../internal/baseIndexOf', '../lang/isArray', '../internal/isLength', '.
if (!length) {
return false;
}
if (typeof fromIndex == 'number') {
fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
} else {
if (typeof fromIndex != 'number' || (guard && isIterateeCall(target, fromIndex, guard))) {
fromIndex = 0;
} else {
fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
}
return (typeof collection == 'string' || !isArray(collection) && isString(collection))
? (fromIndex < length && collection.indexOf(target, fromIndex) > -1)

View File

@@ -4,13 +4,17 @@ define(['../internal/createAggregator'], function(createAggregator) {
* Creates an object composed of keys generated from the results of running
* each element of `collection` through `iteratee`. The corresponding value
* of each key is the last element responsible for generating the key. The
* iteratee function is bound to `thisArg` and invoked with three arguments;
* iteratee function is bound to `thisArg` and invoked with three arguments:
* (value, index|key, collection).
*
* If a property name is provided for `predicate` the created "_.property"
* If a property name is provided for `iteratee` the created `_.property`
* style callback returns the property value of the given element.
*
* If an object is provided for `predicate` the created "_.matches" style
* 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 `iteratee` the created `_.matches` style
* callback returns `true` for elements that have the properties of the given
* object, else `false`.
*
@@ -19,8 +23,7 @@ define(['../internal/createAggregator'], function(createAggregator) {
* @category Collection
* @param {Array|Object|string} collection The collection to iterate over.
* @param {Function|Object|string} [iteratee=_.identity] The function invoked
* per iteration. If a property name or object is provided it is used to
* create a "_.property" or "_.matches" style callback respectively.
* per iteration.
* @param {*} [thisArg] The `this` binding of `iteratee`.
* @returns {Object} Returns the composed aggregate object.
* @example
@@ -33,10 +36,14 @@ define(['../internal/createAggregator'], function(createAggregator) {
* _.indexBy(keyData, 'dir');
* // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
*
* _.indexBy(keyData, function(object) { return String.fromCharCode(object.code); });
* _.indexBy(keyData, function(object) {
* return String.fromCharCode(object.code);
* });
* // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
*
* _.indexBy(keyData, function(object) { return this.fromCharCode(object.code); }, String);
* _.indexBy(keyData, function(object) {
* return this.fromCharCode(object.code);
* }, String);
* // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
*/
var indexBy = createAggregator(function(result, value, key) {

View File

@@ -1,4 +1,7 @@
define(['../internal/baseInvoke', '../internal/baseSlice'], function(baseInvoke, baseSlice) {
define(['../internal/baseEach', '../internal/isLength', '../function/restParam'], function(baseEach, isLength, restParam) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
/**
* Invokes the method named by `methodName` on each element in `collection`,
@@ -22,9 +25,18 @@ define(['../internal/baseInvoke', '../internal/baseSlice'], function(baseInvoke,
* _.invoke([123, 456], String.prototype.split, '');
* // => [['1', '2', '3'], ['4', '5', '6']]
*/
function invoke(collection, methodName) {
return baseInvoke(collection, methodName, baseSlice(arguments, 2));
}
var invoke = restParam(function(collection, methodName, args) {
var index = -1,
isFunc = typeof methodName == 'function',
length = collection ? collection.length : 0,
result = isLength(length) ? Array(length) : [];
baseEach(collection, function(value) {
var func = isFunc ? methodName : (value != null && value[methodName]);
result[++index] = func ? func.apply(value, args) : undefined;
});
return result;
});
return invoke;
});

View File

@@ -3,39 +3,56 @@ define(['../internal/arrayMap', '../internal/baseCallback', '../internal/baseMap
/**
* Creates an array of values by running each element in `collection` through
* `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three
* arguments; (value, index|key, collection).
* arguments: (value, index|key, collection).
*
* If a property name is provided for `predicate` the created "_.property"
* If a property name is provided for `iteratee` the created `_.property`
* style callback returns the property value of the given element.
*
* If an object is provided for `predicate` the created "_.matches" style
* 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 `iteratee` the created `_.matches` style
* callback returns `true` for elements that have the properties of the given
* object, else `false`.
*
* Many lodash methods are guarded to work as interatees for methods like
* `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
*
* The guarded methods are:
* `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`, `drop`,
* `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`, `parseInt`,
* `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`, `trimLeft`,
* `trimRight`, `trunc`, `random`, `range`, `sample`, `some`, `uniq`, and `words`
*
* @static
* @memberOf _
* @alias collect
* @category Collection
* @param {Array|Object|string} collection The collection to iterate over.
* @param {Function|Object|string} [iteratee=_.identity] The function invoked
* per iteration. If a property name or object is provided it is used to
* create a "_.property" or "_.matches" style callback respectively.
* per iteration.
* create a `_.property` or `_.matches` style callback respectively.
* @param {*} [thisArg] The `this` binding of `iteratee`.
* @returns {Array} Returns the new mapped array.
* @example
*
* _.map([1, 2, 3], function(n) { return n * 3; });
* // => [3, 6, 9]
* function timesThree(n) {
* return n * 3;
* }
*
* _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(n) { return n * 3; });
* // => [3, 6, 9] (iteration order is not guaranteed)
* _.map([1, 2], timesThree);
* // => [3, 6]
*
* _.map({ 'a': 1, 'b': 2 }, timesThree);
* // => [3, 6] (iteration order is not guaranteed)
*
* var users = [
* { 'user': 'barney' },
* { 'user': 'fred' }
* ];
*
* // using the "_.property" callback shorthand
* // using the `_.property` callback shorthand
* _.map(users, 'user');
* // => ['barney', 'fred']
*/

View File

@@ -1,49 +1,3 @@
define(['../internal/arrayMax', '../internal/createExtremum'], function(arrayMax, createExtremum) {
/**
* Gets the maximum value of `collection`. If `collection` is empty or falsey
* `-Infinity` is returned. If an iteratee function is provided it is invoked
* for each value in `collection` to generate the criterion by which the value
* is ranked. The `iteratee` is bound to `thisArg` and invoked with three
* arguments; (value, index, collection).
*
* If a property name is provided for `predicate` the created "_.property"
* style callback returns the property value of the given element.
*
* 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
* @memberOf _
* @category Collection
* @param {Array|Object|string} collection The collection to iterate over.
* @param {Function|Object|string} [iteratee] The function invoked per iteration.
* If a property name or object is provided it is used to create a "_.property"
* or "_.matches" style callback respectively.
* @param {*} [thisArg] The `this` binding of `iteratee`.
* @returns {*} Returns the maximum value.
* @example
*
* _.max([4, 2, 8, 6]);
* // => 8
*
* _.max([]);
* // => -Infinity
*
* var users = [
* { 'user': 'barney', 'age': 36 },
* { 'user': 'fred', 'age': 40 }
* ];
*
* _.max(users, function(chr) { return chr.age; });
* // => { 'user': 'fred', 'age': 40 };
*
* // using the "_.property" callback shorthand
* _.max(users, 'age');
* // => { 'user': 'fred', 'age': 40 };
*/
var max = createExtremum(arrayMax);
define(["../math/max"], function(max) {
return max;
});

View File

@@ -1,49 +1,3 @@
define(['../internal/arrayMin', '../internal/createExtremum'], function(arrayMin, createExtremum) {
/**
* Gets the minimum value of `collection`. If `collection` is empty or falsey
* `Infinity` is returned. If an iteratee function is provided it is invoked
* for each value in `collection` to generate the criterion by which the value
* is ranked. The `iteratee` is bound to `thisArg` and invoked with three
* arguments; (value, index, collection).
*
* If a property name is provided for `predicate` the created "_.property"
* style callback returns the property value of the given element.
*
* 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
* @memberOf _
* @category Collection
* @param {Array|Object|string} collection The collection to iterate over.
* @param {Function|Object|string} [iteratee] The function invoked per iteration.
* If a property name or object is provided it is used to create a "_.property"
* or "_.matches" style callback respectively.
* @param {*} [thisArg] The `this` binding of `iteratee`.
* @returns {*} Returns the minimum value.
* @example
*
* _.min([4, 2, 8, 6]);
* // => 2
*
* _.min([]);
* // => Infinity
*
* var users = [
* { 'user': 'barney', 'age': 36 },
* { 'user': 'fred', 'age': 40 }
* ];
*
* _.min(users, function(chr) { return chr.age; });
* // => { 'user': 'barney', 'age': 36 };
*
* // using the "_.property" callback shorthand
* _.min(users, 'age');
* // => { 'user': 'barney', 'age': 36 };
*/
var min = createExtremum(arrayMin, true);
define(["../math/min"], function(min) {
return min;
});

View File

@@ -4,12 +4,16 @@ define(['../internal/createAggregator'], function(createAggregator) {
* Creates an array of elements split into two groups, the first of which
* contains elements `predicate` returns truthy for, while the second of which
* contains elements `predicate` returns falsey for. The predicate is bound
* to `thisArg` and invoked with three arguments; (value, index|key, collection).
* to `thisArg` and invoked with three arguments: (value, index|key, collection).
*
* If a property name is provided for `predicate` the created "_.property"
* If a property name is provided for `predicate` the created `_.property`
* style callback returns the property value of the given element.
*
* If an object is provided for `predicate` the created "_.matches" style
* 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`.
*
@@ -18,17 +22,20 @@ define(['../internal/createAggregator'], function(createAggregator) {
* @category Collection
* @param {Array|Object|string} collection The collection to iterate over.
* @param {Function|Object|string} [predicate=_.identity] The function invoked
* per iteration. If a property name or object is provided it is used to
* create a "_.property" or "_.matches" style callback respectively.
* per iteration.
* @param {*} [thisArg] The `this` binding of `predicate`.
* @returns {Array} Returns the array of grouped elements.
* @example
*
* _.partition([1, 2, 3], function(n) { return n % 2; });
* _.partition([1, 2, 3], function(n) {
* return n % 2;
* });
* // => [[1, 3], [2]]
*
* _.partition([1.2, 2.3, 3.4], function(n) { return this.floor(n) % 2; }, Math);
* // => [[1, 3], [2]]
* _.partition([1.2, 2.3, 3.4], function(n) {
* return this.floor(n) % 2;
* }, Math);
* // => [[1.2, 3.4], [2.3]]
*
* var users = [
* { 'user': 'barney', 'age': 36, 'active': false },
@@ -36,12 +43,20 @@ define(['../internal/createAggregator'], function(createAggregator) {
* { 'user': 'pebbles', 'age': 1, 'active': false }
* ];
*
* // using the "_.matches" callback shorthand
* _.map(_.partition(users, { 'age': 1 }), function(array) { return _.pluck(array, 'user'); });
* var mapper = function(array) {
* return _.pluck(array, 'user');
* };
*
* // using the `_.matches` callback shorthand
* _.map(_.partition(users, { 'age': 1, 'active': false }), mapper);
* // => [['pebbles'], ['barney', 'fred']]
*
* // using the "_.property" callback shorthand
* _.map(_.partition(users, 'active'), function(array) { return _.pluck(array, 'user'); });
* // using the `_.matchesProperty` callback shorthand
* _.map(_.partition(users, 'active', false), mapper);
* // => [['barney', 'pebbles'], ['fred']]
*
* // using the `_.property` callback shorthand
* _.map(_.partition(users, 'active'), mapper);
* // => [['fred'], ['barney', 'pebbles']]
*/
var partition = createAggregator(function(result, value, key) {

View File

@@ -1,4 +1,4 @@
define(['./map', '../utility/property'], function(map, property) {
define(['../internal/baseProperty', './map'], function(baseProperty, map) {
/**
* Gets the value of `key` from all elements in `collection`.
@@ -24,7 +24,7 @@ define(['./map', '../utility/property'], function(map, property) {
* // => [36, 40] (iteration order is not guaranteed)
*/
function pluck(collection, key) {
return map(collection, property(key));
return map(collection, baseProperty(key));
}
return pluck;

View File

@@ -1,13 +1,19 @@
define(['../internal/arrayReduce', '../internal/baseCallback', '../internal/baseEach', '../internal/baseReduce', '../lang/isArray'], function(arrayReduce, baseCallback, baseEach, baseReduce, isArray) {
define(['../internal/arrayReduce', '../internal/baseEach', '../internal/createReduce'], function(arrayReduce, baseEach, createReduce) {
/**
* Reduces `collection` to a value which is the accumulated result of running
* each element in `collection` through `iteratee`, where each successive
* invocation is supplied the return value of the previous. If `accumulator`
* is not provided the first element of `collection` is used as the initial
* 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).
*
* Many lodash methods are guarded to work as interatees for methods like
* `_.reduce`, `_.reduceRight`, and `_.transform`.
*
* The guarded methods are:
* `assign`, `defaults`, `includes`, `merge`, `sortByAll`, and `sortByOrder`
*
* @static
* @memberOf _
* @alias foldl, inject
@@ -19,19 +25,18 @@ define(['../internal/arrayReduce', '../internal/baseCallback', '../internal/base
* @returns {*} Returns the accumulated value.
* @example
*
* var sum = _.reduce([1, 2, 3], function(sum, n) { return sum + n; });
* // => 6
* _.reduce([1, 2], function(sum, n) {
* return sum + n;
* });
* // => 3
*
* var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, n, key) {
* _.reduce({ 'a': 1, 'b': 2 }, function(result, n, key) {
* result[key] = n * 3;
* return result;
* }, {});
* // => { 'a': 3, 'b': 6, 'c': 9 } (iteration order is not guaranteed)
* // => { 'a': 3, 'b': 6 } (iteration order is not guaranteed)
*/
function reduce(collection, iteratee, accumulator, thisArg) {
var func = isArray(collection) ? arrayReduce : baseReduce;
return func(collection, baseCallback(iteratee, thisArg, 4), accumulator, arguments.length < 3, baseEach);
}
var reduce = createReduce(arrayReduce, baseEach);
return reduce;
});

View File

@@ -1,4 +1,4 @@
define(['../internal/arrayReduceRight', '../internal/baseCallback', '../internal/baseEachRight', '../internal/baseReduce', '../lang/isArray'], function(arrayReduceRight, baseCallback, baseEachRight, baseReduce, isArray) {
define(['../internal/arrayReduceRight', '../internal/baseEachRight', '../internal/createReduce'], function(arrayReduceRight, baseEachRight, createReduce) {
/**
* This method is like `_.reduce` except that it iterates over elements of
@@ -16,13 +16,13 @@ define(['../internal/arrayReduceRight', '../internal/baseCallback', '../internal
* @example
*
* var array = [[0, 1], [2, 3], [4, 5]];
* _.reduceRight(array, function(flattened, other) { return flattened.concat(other); }, []);
*
* _.reduceRight(array, function(flattened, other) {
* return flattened.concat(other);
* }, []);
* // => [4, 5, 2, 3, 0, 1]
*/
function reduceRight(collection, iteratee, accumulator, thisArg) {
var func = isArray(collection) ? arrayReduceRight : baseReduce;
return func(collection, baseCallback(iteratee, thisArg, 4), accumulator, arguments.length < 3, baseEachRight);
}
var reduceRight = createReduce(arrayReduceRight, baseEachRight);
return reduceRight;
});

View File

@@ -4,10 +4,14 @@ define(['../internal/arrayFilter', '../internal/baseCallback', '../internal/base
* The opposite of `_.filter`; this method returns the elements of `collection`
* that `predicate` does **not** return truthy for.
*
* If a property name is provided for `predicate` the created "_.property"
* If a property name is provided for `predicate` the created `_.property`
* style callback returns the property value of the given element.
*
* If an object is provided for `predicate` the created "_.matches" style
* 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`.
*
@@ -16,13 +20,14 @@ define(['../internal/arrayFilter', '../internal/baseCallback', '../internal/base
* @category Collection
* @param {Array|Object|string} collection The collection to iterate over.
* @param {Function|Object|string} [predicate=_.identity] The function invoked
* per iteration. If a property name or object is provided it is used to
* create a "_.property" or "_.matches" style callback respectively.
* per iteration.
* @param {*} [thisArg] The `this` binding of `predicate`.
* @returns {Array} Returns the new filtered array.
* @example
*
* var odds = _.reject([1, 2, 3, 4], function(n) { return n % 2 == 0; });
* _.reject([1, 2, 3, 4], function(n) {
* return n % 2 == 0;
* });
* // => [1, 3]
*
* var users = [
@@ -30,13 +35,17 @@ define(['../internal/arrayFilter', '../internal/baseCallback', '../internal/base
* { 'user': 'fred', 'age': 40, 'active': true }
* ];
*
* // using the "_.property" callback shorthand
* _.pluck(_.reject(users, 'active'), 'user');
* // using the `_.matches` callback shorthand
* _.pluck(_.reject(users, { 'age': 40, 'active': true }), 'user');
* // => ['barney']
*
* // using the "_.matches" callback shorthand
* _.pluck(_.reject(users, { 'age': 36 }), 'user');
* // using the `_.matchesProperty` callback shorthand
* _.pluck(_.reject(users, 'active', false), 'user');
* // => ['fred']
*
* // using the `_.property` callback shorthand
* _.pluck(_.reject(users, 'active'), 'user');
* // => ['barney']
*/
function reject(collection, predicate, thisArg) {
var func = isArray(collection) ? arrayFilter : baseFilter;

View File

@@ -1,9 +1,8 @@
define(['../internal/baseRandom', '../internal/toIterable'], function(baseRandom, toIterable) {
/**
* Creates an array of shuffled values, using a version of the Fisher-Yates
* shuffle. See [Wikipedia](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle)
* for more details.
* Creates an array of shuffled values, using a version of the
* [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher-Yates_shuffle).
*
* @static
* @memberOf _

View File

@@ -1,8 +1,8 @@
define(['../internal/isLength', '../object/keys'], function(isLength, keys) {
/**
* Gets the size of `collection` by returning `collection.length` for
* array-like values or the number of own enumerable properties for objects.
* Gets the size of `collection` by returning its length for array-like
* values or the number of own enumerable properties for objects.
*
* @static
* @memberOf _
@@ -11,12 +11,12 @@ define(['../internal/isLength', '../object/keys'], function(isLength, keys) {
* @returns {number} Returns the size of `collection`.
* @example
*
* _.size([1, 2]);
* // => 2
*
* _.size({ 'one': 1, 'two': 2, 'three': 3 });
* _.size([1, 2, 3]);
* // => 3
*
* _.size({ 'a': 1, 'b': 2 });
* // => 2
*
* _.size('pebbles');
* // => 7
*/

View File

@@ -1,15 +1,19 @@
define(['../internal/arraySome', '../internal/baseCallback', '../internal/baseSome', '../lang/isArray'], function(arraySome, baseCallback, baseSome, isArray) {
define(['../internal/arraySome', '../internal/baseCallback', '../internal/baseSome', '../lang/isArray', '../internal/isIterateeCall'], function(arraySome, baseCallback, baseSome, isArray, isIterateeCall) {
/**
* Checks if `predicate` returns truthy for **any** element of `collection`.
* The function returns as soon as it finds a passing value and does not iterate
* over the entire collection. The predicate is bound to `thisArg` and invoked
* with three arguments; (value, index|key, collection).
* with three arguments: (value, index|key, collection).
*
* If a property name is provided for `predicate` the created "_.property"
* If a property name is provided for `predicate` the created `_.property`
* style callback returns the property value of the given element.
*
* If an object is provided for `predicate` the created "_.matches" style
* 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`.
*
@@ -19,8 +23,7 @@ define(['../internal/arraySome', '../internal/baseCallback', '../internal/baseSo
* @category Collection
* @param {Array|Object|string} collection The collection to iterate over.
* @param {Function|Object|string} [predicate=_.identity] The function invoked
* per iteration. If a property name or object is provided it is used to
* create a "_.property" or "_.matches" style callback respectively.
* per iteration.
* @param {*} [thisArg] The `this` binding of `predicate`.
* @returns {boolean} Returns `true` if any element passes the predicate check,
* else `false`.
@@ -30,20 +33,27 @@ define(['../internal/arraySome', '../internal/baseCallback', '../internal/baseSo
* // => true
*
* var users = [
* { 'user': 'barney', 'age': 36, 'active': false },
* { 'user': 'fred', 'age': 40, 'active': true }
* { 'user': 'barney', 'active': true },
* { 'user': 'fred', 'active': false }
* ];
*
* // using the "_.property" callback shorthand
* _.some(users, 'active');
* // using the `_.matches` callback shorthand
* _.some(users, { 'user': 'barney', 'active': false });
* // => false
*
* // using the `_.matchesProperty` callback shorthand
* _.some(users, 'active', false);
* // => true
*
* // using the "_.matches" callback shorthand
* _.some(users, { 'age': 1 });
* // => false
* // using the `_.property` callback shorthand
* _.some(users, 'active');
* // => true
*/
function some(collection, predicate, thisArg) {
var func = isArray(collection) ? arraySome : baseSome;
if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
predicate = null;
}
if (typeof predicate != 'function' || typeof thisArg != 'undefined') {
predicate = baseCallback(predicate, thisArg, 3);
}

View File

@@ -4,13 +4,17 @@ define(['../internal/baseCallback', '../internal/baseEach', '../internal/baseSor
* Creates an array of elements, sorted in ascending order by the results of
* running each element in a collection through `iteratee`. This method performs
* a stable sort, that is, it preserves the original sort order of equal elements.
* The `iteratee` is bound to `thisArg` and invoked with three arguments;
* The `iteratee` is bound to `thisArg` and invoked with three arguments:
* (value, index|key, collection).
*
* If a property name is provided for `predicate` the created "_.property"
* If a property name is provided for `iteratee` the created `_.property`
* style callback returns the property value of the given element.
*
* If an object is provided for `predicate` the created "_.matches" style
* 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 `iteratee` the created `_.matches` style
* callback returns `true` for elements that have the properties of the given
* object, else `false`.
*
@@ -20,15 +24,19 @@ define(['../internal/baseCallback', '../internal/baseEach', '../internal/baseSor
* @param {Array|Object|string} collection The collection to iterate over.
* @param {Array|Function|Object|string} [iteratee=_.identity] The function
* invoked per iteration. If a property name or an object is provided it is
* used to create a "_.property" or "_.matches" style callback respectively.
* used to create a `_.property` or `_.matches` style callback respectively.
* @param {*} [thisArg] The `this` binding of `iteratee`.
* @returns {Array} Returns the new sorted array.
* @example
*
* _.sortBy([1, 2, 3], function(n) { return Math.sin(n); });
* _.sortBy([1, 2, 3], function(n) {
* return Math.sin(n);
* });
* // => [3, 1, 2]
*
* _.sortBy([1, 2, 3], function(n) { return this.sin(n); }, Math);
* _.sortBy([1, 2, 3], function(n) {
* return this.sin(n);
* }, Math);
* // => [3, 1, 2]
*
* var users = [
@@ -37,13 +45,16 @@ define(['../internal/baseCallback', '../internal/baseEach', '../internal/baseSor
* { 'user': 'barney' }
* ];
*
* // using the "_.property" callback shorthand
* // using the `_.property` callback shorthand
* _.pluck(_.sortBy(users, 'user'), 'user');
* // => ['barney', 'fred', 'pebbles']
*/
function sortBy(collection, iteratee, thisArg) {
if (collection == null) {
return [];
}
var index = -1,
length = collection ? collection.length : 0,
length = collection.length,
result = isLength(length) ? Array(length) : [];
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {

View File

@@ -1,7 +1,4 @@
define(['../internal/baseEach', '../internal/baseFlatten', '../internal/baseSortBy', '../internal/compareMultipleAscending', '../internal/isIterateeCall', '../internal/isLength'], function(baseEach, baseFlatten, baseSortBy, compareMultipleAscending, isIterateeCall, isLength) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
define(['../internal/baseFlatten', '../internal/baseSortByOrder', '../internal/isIterateeCall'], function(baseFlatten, baseSortByOrder, isIterateeCall) {
/**
* This method is like `_.sortBy` except that it sorts by property names
@@ -26,26 +23,24 @@ define(['../internal/baseEach', '../internal/baseFlatten', '../internal/baseSort
* _.map(_.sortByAll(users, ['user', 'age']), _.values);
* // => [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]]
*/
function sortByAll(collection) {
var args = arguments;
if (args.length > 3 && isIterateeCall(args[1], args[2], args[3])) {
args = [collection, args[1]];
function sortByAll() {
var args = arguments,
collection = args[0],
guard = args[3],
index = 0,
length = args.length - 1;
if (collection == null) {
return [];
}
var index = -1,
length = collection ? collection.length : 0,
props = baseFlatten(args, false, false, 1),
result = isLength(length) ? Array(length) : [];
baseEach(collection, function(value, key, collection) {
var length = props.length,
criteria = Array(length);
while (length--) {
criteria[length] = value == null ? undefined : value[props[length]];
}
result[++index] = { 'criteria': criteria, 'index': index, 'value': value };
});
return baseSortBy(result, compareMultipleAscending);
var props = Array(length);
while (index < length) {
props[index] = args[++index];
}
if (guard && isIterateeCall(args[1], args[2], guard)) {
props = args[1];
}
return baseSortByOrder(collection, baseFlatten(props), []);
}
return sortByAll;

47
collection/sortByOrder.js Normal file
View File

@@ -0,0 +1,47 @@
define(['../internal/baseSortByOrder', '../lang/isArray', '../internal/isIterateeCall'], function(baseSortByOrder, isArray, isIterateeCall) {
/**
* This method is like `_.sortByAll` except that it allows specifying the
* sort orders of the property names to sort by. A truthy value in `orders`
* will sort the corresponding property name in ascending order while a
* falsey value will sort it in descending order.
*
* @static
* @memberOf _
* @category Collection
* @param {Array|Object|string} collection The collection to iterate over.
* @param {string[]} props The property names to sort by.
* @param {boolean[]} orders The sort orders of `props`.
* @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`.
* @returns {Array} Returns the new sorted array.
* @example
*
* var users = [
* { 'user': 'barney', 'age': 26 },
* { 'user': 'fred', 'age': 40 },
* { 'user': 'barney', 'age': 36 },
* { 'user': 'fred', 'age': 30 }
* ];
*
* // sort by `user` in ascending order and by `age` in descending order
* _.map(_.sortByOrder(users, ['user', 'age'], [true, false]), _.values);
* // => [['barney', 36], ['barney', 26], ['fred', 40], ['fred', 30]]
*/
function sortByOrder(collection, props, orders, guard) {
if (collection == null) {
return [];
}
if (guard && isIterateeCall(props, orders, guard)) {
orders = null;
}
if (!isArray(props)) {
props = props == null ? [] : [props];
}
if (!isArray(orders)) {
orders = orders == null ? [] : [orders];
}
return baseSortByOrder(collection, props, orders);
}
return sortByOrder;
});

3
collection/sum.js Normal file
View File

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

View File

@@ -1,10 +1,15 @@
define(['./filter', '../utility/matches'], function(filter, matches) {
define(['../internal/baseMatches', './filter'], function(baseMatches, filter) {
/**
* Performs a deep comparison between each element in `collection` and the
* source object, returning an array of all elements that have equivalent
* property values.
*
* **Note:** This method supports comparing arrays, booleans, `Date` objects,
* numbers, `Object` objects, regexes, and strings. Objects are compared by
* their own, not inherited, enumerable properties. For comparing a single
* own or inherited property value see `_.matchesProperty`.
*
* @static
* @memberOf _
* @category Collection
@@ -14,21 +19,18 @@ define(['./filter', '../utility/matches'], function(filter, matches) {
* @example
*
* var users = [
* { 'user': 'barney', 'age': 36, 'status': 'busy', 'pets': ['hoppy'] },
* { 'user': 'fred', 'age': 40, 'status': 'busy', 'pets': ['baby puss', 'dino'] }
* { 'user': 'barney', 'age': 36, 'active': false, 'pets': ['hoppy'] },
* { 'user': 'fred', 'age': 40, 'active': true, 'pets': ['baby puss', 'dino'] }
* ];
*
* _.pluck(_.where(users, { 'age': 36 }), 'user');
* _.pluck(_.where(users, { 'age': 36, 'active': false }), 'user');
* // => ['barney']
*
* _.pluck(_.where(users, { 'pets': ['dino'] }), 'user');
* // => ['fred']
*
* _.pluck(_.where(users, { 'status': 'busy' }), 'user');
* // => ['barney', 'fred']
*/
function where(collection, source) {
return filter(collection, matches(source));
return filter(collection, baseMatches(source));
}
return where;

View File

@@ -12,7 +12,9 @@ define(['../lang/isNative'], function(isNative) {
* @category Date
* @example
*
* _.defer(function(stamp) { console.log(_.now() - stamp); }, _.now());
* _.defer(function(stamp) {
* console.log(_.now() - stamp);
* }, _.now());
* // => logs the number of milliseconds it took for the deferred function to be invoked
*/
var now = nativeNow || function() {

View File

@@ -1,4 +1,4 @@
define(['./function/after', './function/ary', './function/backflow', './function/before', './function/bind', './function/bindAll', './function/bindKey', './function/compose', './function/curry', './function/curryRight', './function/debounce', './function/defer', './function/delay', './function/flow', './function/flowRight', './function/memoize', './function/negate', './function/once', './function/partial', './function/partialRight', './function/rearg', './function/throttle', './function/wrap'], function(after, ary, backflow, before, bind, bindAll, bindKey, compose, curry, curryRight, debounce, defer, delay, flow, flowRight, memoize, negate, once, partial, partialRight, rearg, throttle, wrap) {
define(['./function/after', './function/ary', './function/backflow', './function/before', './function/bind', './function/bindAll', './function/bindKey', './function/compose', './function/curry', './function/curryRight', './function/debounce', './function/defer', './function/delay', './function/flow', './function/flowRight', './function/memoize', './function/negate', './function/once', './function/partial', './function/partialRight', './function/rearg', './function/restParam', './function/spread', './function/throttle', './function/wrap'], function(after, ary, backflow, before, bind, bindAll, bindKey, compose, curry, curryRight, debounce, defer, delay, flow, flowRight, memoize, negate, once, partial, partialRight, rearg, restParam, spread, throttle, wrap) {
return {
'after': after,
'ary': ary,
@@ -21,6 +21,8 @@ define(['./function/after', './function/ary', './function/backflow', './function
'partial': partial,
'partialRight': partialRight,
'rearg': rearg,
'restParam': restParam,
'spread': spread,
'throttle': throttle,
'wrap': wrap
};

View File

@@ -1,4 +1,4 @@
define(['../lang/isFunction', '../internal/root'], function(isFunction, root) {
define(['../internal/root'], function(root) {
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
@@ -30,8 +30,8 @@ define(['../lang/isFunction', '../internal/root'], function(isFunction, root) {
* // => logs 'done saving!' after the two async saves have completed
*/
function after(n, func) {
if (!isFunction(func)) {
if (isFunction(n)) {
if (typeof func != 'function') {
if (typeof n == 'function') {
var temp = n;
n = func;
func = temp;

View File

@@ -1,7 +1,7 @@
define(['../internal/createWrapper', '../internal/isIterateeCall'], function(createWrapper, isIterateeCall) {
/** Used to compose bitmasks for wrapper metadata. */
var ARY_FLAG = 256;
var ARY_FLAG = 128;
/* Native method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max;

View File

@@ -1,4 +1,4 @@
define(['../lang/isFunction'], function(isFunction) {
define([], function() {
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
@@ -21,8 +21,8 @@ define(['../lang/isFunction'], function(isFunction) {
*/
function before(n, func) {
var result;
if (!isFunction(func)) {
if (isFunction(n)) {
if (typeof func != 'function') {
if (typeof n == 'function') {
var temp = n;
n = func;
func = temp;

View File

@@ -1,4 +1,4 @@
define(['../internal/baseSlice', '../internal/createWrapper', '../internal/replaceHolders'], function(baseSlice, createWrapper, replaceHolders) {
define(['../internal/createWrapper', '../internal/replaceHolders', './restParam'], function(createWrapper, replaceHolders, restParam) {
/** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1,
@@ -20,7 +20,7 @@ define(['../internal/baseSlice', '../internal/createWrapper', '../internal/repla
* @category Function
* @param {Function} func The function to bind.
* @param {*} thisArg The `this` binding of `func`.
* @param {...*} [args] The arguments to be partially applied.
* @param {...*} [partials] The arguments to be partially applied.
* @returns {Function} Returns the new bound function.
* @example
*
@@ -39,16 +39,14 @@ define(['../internal/baseSlice', '../internal/createWrapper', '../internal/repla
* bound('hi');
* // => 'hi fred!'
*/
function bind(func, thisArg) {
var bind = restParam(function(func, thisArg, partials) {
var bitmask = BIND_FLAG;
if (arguments.length > 2) {
var partials = baseSlice(arguments, 2),
holders = replaceHolders(partials, bind.placeholder);
if (partials.length) {
var holders = replaceHolders(partials, bind.placeholder);
bitmask |= PARTIAL_FLAG;
}
return createWrapper(func, bitmask, thisArg, partials, holders);
}
});
// Assign default placeholders.
bind.placeholder = {};

View File

@@ -1,4 +1,7 @@
define(['../internal/baseBindAll', '../internal/baseFlatten', '../object/functions'], function(baseBindAll, baseFlatten, functions) {
define(['../internal/baseFlatten', '../internal/createWrapper', '../object/functions', './restParam'], function(baseFlatten, createWrapper, functions, restParam) {
/** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1;
/**
* Binds methods of an object to the object itself, overwriting the existing
@@ -19,20 +22,27 @@ define(['../internal/baseBindAll', '../internal/baseFlatten', '../object/functio
*
* var view = {
* 'label': 'docs',
* 'onClick': function() { console.log('clicked ' + this.label); }
* 'onClick': function() {
* console.log('clicked ' + this.label);
* }
* };
*
* _.bindAll(view);
* jQuery('#docs').on('click', view.onClick);
* // => logs 'clicked docs' when the element is clicked
*/
function bindAll(object) {
return baseBindAll(object,
arguments.length > 1
? baseFlatten(arguments, false, false, 1)
: functions(object)
);
}
var bindAll = restParam(function(object, methodNames) {
methodNames = methodNames.length ? baseFlatten(methodNames) : functions(object);
var index = -1,
length = methodNames.length;
while (++index < length) {
var key = methodNames[index];
object[key] = createWrapper(object[key], BIND_FLAG, object);
}
return object;
});
return bindAll;
});

View File

@@ -1,4 +1,4 @@
define(['../internal/baseSlice', '../internal/createWrapper', '../internal/replaceHolders'], function(baseSlice, createWrapper, replaceHolders) {
define(['../internal/createWrapper', '../internal/replaceHolders', './restParam'], function(createWrapper, replaceHolders, restParam) {
/** Used to compose bitmasks for wrapper metadata. */
var BIND_FLAG = 1,
@@ -22,7 +22,7 @@ define(['../internal/baseSlice', '../internal/createWrapper', '../internal/repla
* @category Function
* @param {Object} object The object the method belongs to.
* @param {string} key The key of the method.
* @param {...*} [args] The arguments to be partially applied.
* @param {...*} [partials] The arguments to be partially applied.
* @returns {Function} Returns the new bound function.
* @example
*
@@ -49,16 +49,14 @@ define(['../internal/baseSlice', '../internal/createWrapper', '../internal/repla
* bound('hi');
* // => 'hiya fred!'
*/
function bindKey(object, key) {
var bindKey = restParam(function(object, key, partials) {
var bitmask = BIND_FLAG | BIND_KEY_FLAG;
if (arguments.length > 2) {
var partials = baseSlice(arguments, 2),
holders = replaceHolders(partials, bindKey.placeholder);
if (partials.length) {
var holders = replaceHolders(partials, bindKey.placeholder);
bitmask |= PARTIAL_FLAG;
}
return createWrapper(key, bitmask, object, partials, holders);
}
});
// Assign default placeholders.
bindKey.placeholder = {};

View File

@@ -1,4 +1,4 @@
define(['../internal/createWrapper', '../internal/isIterateeCall'], function(createWrapper, isIterateeCall) {
define(['../internal/createCurry'], function(createCurry) {
/** Used to compose bitmasks for wrapper metadata. */
var CURRY_FLAG = 8;
@@ -43,14 +43,7 @@ define(['../internal/createWrapper', '../internal/isIterateeCall'], function(cre
* curried(1)(_, 3)(2);
* // => [1, 2, 3]
*/
function curry(func, arity, guard) {
if (guard && isIterateeCall(func, arity, guard)) {
arity = null;
}
var result = createWrapper(func, CURRY_FLAG, null, null, null, null, null, arity);
result.placeholder = curry.placeholder;
return result;
}
var curry = createCurry(CURRY_FLAG);
// Assign default placeholders.
curry.placeholder = {};

View File

@@ -1,4 +1,4 @@
define(['../internal/createWrapper', '../internal/isIterateeCall'], function(createWrapper, isIterateeCall) {
define(['../internal/createCurry'], function(createCurry) {
/** Used to compose bitmasks for wrapper metadata. */
var CURRY_RIGHT_FLAG = 16;
@@ -40,14 +40,7 @@ define(['../internal/createWrapper', '../internal/isIterateeCall'], function(cre
* curried(3)(1, _)(2);
* // => [1, 2, 3]
*/
function curryRight(func, arity, guard) {
if (guard && isIterateeCall(func, arity, guard)) {
arity = null;
}
var result = createWrapper(func, CURRY_RIGHT_FLAG, null, null, null, null, null, arity);
result.placeholder = curryRight.placeholder;
return result;
}
var curryRight = createCurry(CURRY_RIGHT_FLAG);
// Assign default placeholders.
curryRight.placeholder = {};

View File

@@ -1,4 +1,4 @@
define(['../lang/isFunction', '../lang/isObject', '../date/now'], function(isFunction, isObject, now) {
define(['../lang/isObject', '../date/now'], function(isObject, now) {
/** Used as a safe reference for `undefined` in pre-ES5 environments. */
var undefined;
@@ -28,7 +28,7 @@ define(['../lang/isFunction', '../lang/isObject', '../date/now'], function(isFun
* @memberOf _
* @category Function
* @param {Function} func The function to debounce.
* @param {number} wait The number of milliseconds to delay.
* @param {number} [wait=0] The number of milliseconds to delay.
* @param {Object} [options] The options object.
* @param {boolean} [options.leading=false] Specify invoking on the leading
* edge of the timeout.
@@ -83,10 +83,10 @@ define(['../lang/isFunction', '../lang/isObject', '../date/now'], function(isFun
maxWait = false,
trailing = true;
if (!isFunction(func)) {
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
wait = wait < 0 ? 0 : wait;
wait = wait < 0 ? 0 : (+wait || 0);
if (options === true) {
var leading = true;
trailing = false;

View File

@@ -1,4 +1,4 @@
define(['../internal/baseDelay'], function(baseDelay) {
define(['../internal/baseDelay', './restParam'], function(baseDelay, restParam) {
/**
* Defers invoking the `func` until the current call stack has cleared. Any
@@ -12,12 +12,14 @@ define(['../internal/baseDelay'], function(baseDelay) {
* @returns {number} Returns the timer id.
* @example
*
* _.defer(function(text) { console.log(text); }, 'deferred');
* _.defer(function(text) {
* console.log(text);
* }, 'deferred');
* // logs 'deferred' after one or more milliseconds
*/
function defer(func) {
return baseDelay(func, 1, arguments, 1);
}
var defer = restParam(function(func, args) {
return baseDelay(func, 1, args);
});
return defer;
});

View File

@@ -1,4 +1,4 @@
define(['../internal/baseDelay'], function(baseDelay) {
define(['../internal/baseDelay', './restParam'], function(baseDelay, restParam) {
/**
* Invokes `func` after `wait` milliseconds. Any additional arguments are
@@ -13,12 +13,14 @@ define(['../internal/baseDelay'], function(baseDelay) {
* @returns {number} Returns the timer id.
* @example
*
* _.delay(function(text) { console.log(text); }, 1000, 'later');
* _.delay(function(text) {
* console.log(text);
* }, 1000, 'later');
* // => logs 'later' after one second
*/
function delay(func, wait) {
return baseDelay(func, wait, arguments, 2);
}
var delay = restParam(function(func, wait, args) {
return baseDelay(func, wait, args);
});
return delay;
});

View File

@@ -1,7 +1,4 @@
define(['../internal/arrayEvery', '../lang/isFunction'], function(arrayEvery, isFunction) {
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
define(['../internal/createFlow'], function(createFlow) {
/**
* Creates a function that returns the result of invoking the provided
@@ -15,38 +12,15 @@ define(['../internal/arrayEvery', '../lang/isFunction'], function(arrayEvery, is
* @returns {Function} Returns the new function.
* @example
*
* function add(x, y) {
* return x + y;
* }
*
* function square(n) {
* return n * n;
* }
*
* var addSquare = _.flow(add, square);
* var addSquare = _.flow(_.add, square);
* addSquare(1, 2);
* // => 9
*/
function flow() {
var funcs = arguments,
length = funcs.length;
if (!length) {
return function() {};
}
if (!arrayEvery(funcs, isFunction)) {
throw new TypeError(FUNC_ERROR_TEXT);
}
return function() {
var index = 0,
result = funcs[index].apply(this, arguments);
while (++index < length) {
result = funcs[index].call(this, result);
}
return result;
};
}
var flow = createFlow();
return flow;
});

View File

@@ -1,7 +1,4 @@
define(['../internal/arrayEvery', '../lang/isFunction'], function(arrayEvery, isFunction) {
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
define(['../internal/createFlow'], function(createFlow) {
/**
* This method is like `_.flow` except that it creates a function that
@@ -15,38 +12,15 @@ define(['../internal/arrayEvery', '../lang/isFunction'], function(arrayEvery, is
* @returns {Function} Returns the new function.
* @example
*
* function add(x, y) {
* return x + y;
* }
*
* function square(n) {
* return n * n;
* }
*
* var addSquare = _.flowRight(square, add);
* var addSquare = _.flowRight(square, _.add);
* addSquare(1, 2);
* // => 9
*/
function flowRight() {
var funcs = arguments,
fromIndex = funcs.length - 1;
if (fromIndex < 0) {
return function() {};
}
if (!arrayEvery(funcs, isFunction)) {
throw new TypeError(FUNC_ERROR_TEXT);
}
return function() {
var index = fromIndex,
result = funcs[index].apply(this, arguments);
while (index--) {
result = funcs[index].call(this, result);
}
return result;
};
}
var flowRight = createFlow(true);
return flowRight;
});

View File

@@ -1,4 +1,4 @@
define(['../internal/MapCache', '../lang/isFunction'], function(MapCache, isFunction) {
define(['../internal/MapCache'], function(MapCache) {
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
@@ -13,10 +13,8 @@ define(['../internal/MapCache', '../lang/isFunction'], function(MapCache, isFunc
*
* **Note:** The cache is exposed as the `cache` property on the memoized
* function. Its creation may be customized by replacing the `_.memoize.Cache`
* constructor with one whose instances implement the ES `Map` method interface
* of `get`, `has`, and `set`. See the
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-properties-of-the-map-prototype-object)
* for more details.
* constructor with one whose instances implement the [`Map`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-properties-of-the-map-prototype-object)
* method interface of `get`, `has`, and `set`.
*
* @static
* @memberOf _
@@ -34,7 +32,7 @@ define(['../internal/MapCache', '../lang/isFunction'], function(MapCache, isFunc
* // => 'FRED'
*
* // modifying the result cache
* upperCase.cache.set('fred, 'BARNEY');
* upperCase.cache.set('fred', 'BARNEY');
* upperCase('fred');
* // => 'BARNEY'
*
@@ -57,17 +55,18 @@ define(['../internal/MapCache', '../lang/isFunction'], function(MapCache, isFunc
* // => { 'user': 'barney' }
*/
function memoize(func, resolver) {
if (!isFunction(func) || (resolver && !isFunction(resolver))) {
if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
throw new TypeError(FUNC_ERROR_TEXT);
}
var memoized = function() {
var cache = memoized.cache,
key = resolver ? resolver.apply(this, arguments) : arguments[0];
var args = arguments,
cache = memoized.cache,
key = resolver ? resolver.apply(this, args) : args[0];
if (cache.has(key)) {
return cache.get(key);
}
var result = func.apply(this, arguments);
var result = func.apply(this, args);
cache.set(key, result);
return result;
};

View File

@@ -1,4 +1,4 @@
define(['../lang/isFunction'], function(isFunction) {
define([], function() {
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
@@ -23,7 +23,7 @@ define(['../lang/isFunction'], function(isFunction) {
* // => [1, 3, 5]
*/
function negate(predicate) {
if (!isFunction(predicate)) {
if (typeof predicate != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
return function() {

View File

@@ -3,11 +3,10 @@ define(['./before'], function(before) {
/**
* Creates a function that is restricted to invoking `func` once. Repeat calls
* to the function return the value of the first call. The `func` is invoked
* with the `this` binding of the created function.
* with the `this` binding and arguments of the created function.
*
* @static
* @memberOf _
* @type Function
* @category Function
* @param {Function} func The function to restrict.
* @returns {Function} Returns the new restricted function.

View File

@@ -1,4 +1,4 @@
define(['../internal/baseSlice', '../internal/createWrapper', '../internal/replaceHolders'], function(baseSlice, createWrapper, replaceHolders) {
define(['../internal/createPartial'], function(createPartial) {
/** Used to compose bitmasks for wrapper metadata. */
var PARTIAL_FLAG = 32;
@@ -18,7 +18,7 @@ define(['../internal/baseSlice', '../internal/createWrapper', '../internal/repla
* @memberOf _
* @category Function
* @param {Function} func The function to partially apply arguments to.
* @param {...*} [args] The arguments to be partially applied.
* @param {...*} [partials] The arguments to be partially applied.
* @returns {Function} Returns the new partially applied function.
* @example
*
@@ -35,12 +35,7 @@ define(['../internal/baseSlice', '../internal/createWrapper', '../internal/repla
* greetFred('hi');
* // => 'hi fred'
*/
function partial(func) {
var partials = baseSlice(arguments, 1),
holders = replaceHolders(partials, partial.placeholder);
return createWrapper(func, PARTIAL_FLAG, null, partials, holders);
}
var partial = createPartial(PARTIAL_FLAG);
// Assign default placeholders.
partial.placeholder = {};

View File

@@ -1,4 +1,4 @@
define(['../internal/baseSlice', '../internal/createWrapper', '../internal/replaceHolders'], function(baseSlice, createWrapper, replaceHolders) {
define(['../internal/createPartial'], function(createPartial) {
/** Used to compose bitmasks for wrapper metadata. */
var PARTIAL_RIGHT_FLAG = 64;
@@ -17,7 +17,7 @@ define(['../internal/baseSlice', '../internal/createWrapper', '../internal/repla
* @memberOf _
* @category Function
* @param {Function} func The function to partially apply arguments to.
* @param {...*} [args] The arguments to be partially applied.
* @param {...*} [partials] The arguments to be partially applied.
* @returns {Function} Returns the new partially applied function.
* @example
*
@@ -34,12 +34,7 @@ define(['../internal/baseSlice', '../internal/createWrapper', '../internal/repla
* sayHelloTo('fred');
* // => 'hello fred'
*/
function partialRight(func) {
var partials = baseSlice(arguments, 1),
holders = replaceHolders(partials, partialRight.placeholder);
return createWrapper(func, PARTIAL_RIGHT_FLAG, null, partials, holders);
}
var partialRight = createPartial(PARTIAL_RIGHT_FLAG);
// Assign default placeholders.
partialRight.placeholder = {};

View File

@@ -1,7 +1,7 @@
define(['../internal/baseFlatten', '../internal/createWrapper'], function(baseFlatten, createWrapper) {
define(['../internal/baseFlatten', '../internal/createWrapper', './restParam'], function(baseFlatten, createWrapper, restParam) {
/** Used to compose bitmasks for wrapper metadata. */
var REARG_FLAG = 128;
var REARG_FLAG = 256;
/**
* Creates a function that invokes `func` with arguments arranged according
@@ -26,13 +26,14 @@ define(['../internal/baseFlatten', '../internal/createWrapper'], function(baseFl
* // => ['a', 'b', 'c']
*
* var map = _.rearg(_.map, [1, 0]);
* map(function(n) { return n * 3; }, [1, 2, 3]);
* map(function(n) {
* return n * 3;
* }, [1, 2, 3]);
* // => [3, 6, 9]
*/
function rearg(func) {
var indexes = baseFlatten(arguments, false, false, 1);
return createWrapper(func, REARG_FLAG, null, null, null, indexes);
}
var rearg = restParam(function(func, indexes) {
return createWrapper(func, REARG_FLAG, null, null, null, baseFlatten(indexes));
});
return rearg;
});

61
function/restParam.js Normal file
View File

@@ -0,0 +1,61 @@
define([], function() {
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/* Native method references for those with the same name as other `lodash` methods. */
var nativeMax = Math.max;
/**
* Creates a function that invokes `func` with the `this` binding of the
* created function and arguments from `start` and beyond provided as an array.
*
* **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters).
*
* @static
* @memberOf _
* @category Function
* @param {Function} func The function to apply a rest parameter to.
* @param {number} [start=func.length-1] The start position of the rest parameter.
* @returns {Function} Returns the new function.
* @example
*
* var say = _.restParam(function(what, names) {
* return what + ' ' + _.initial(names).join(', ') +
* (_.size(names) > 1 ? ', & ' : '') + _.last(names);
* });
*
* say('hello', 'fred', 'barney', 'pebbles');
* // => 'hello fred, barney, & pebbles'
*/
function restParam(func, start) {
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
start = nativeMax(typeof start == 'undefined' ? (func.length - 1) : (+start || 0), 0);
return function() {
var args = arguments,
index = -1,
length = nativeMax(args.length - start, 0),
rest = Array(length);
while (++index < length) {
rest[index] = args[start + index];
}
switch (start) {
case 0: return func.call(this, rest);
case 1: return func.call(this, args[0], rest);
case 2: return func.call(this, args[0], args[1], rest);
}
var otherArgs = Array(start + 1);
index = -1;
while (++index < start) {
otherArgs[index] = args[index];
}
otherArgs[start] = rest;
return func.apply(this, otherArgs);
};
}
return restParam;
});

47
function/spread.js Normal file
View File

@@ -0,0 +1,47 @@
define([], function() {
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
/**
* Creates a function that invokes `func` with the `this` binding of the created
* function and an array of arguments much like [`Function#apply`](https://es5.github.io/#x15.3.4.3).
*
* **Note:** This method is based on the [spread operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator).
*
* @static
* @memberOf _
* @category Function
* @param {Function} func The function to spread arguments over.
* @returns {Function} Returns the new function.
* @example
*
* var say = _.spread(function(who, what) {
* return who + ' says ' + what;
* });
*
* say(['fred', 'hello']);
* // => 'fred says hello'
*
* // with a Promise
* var numbers = Promise.all([
* Promise.resolve(40),
* Promise.resolve(36)
* ]);
*
* numbers.then(_.spread(function(x, y) {
* return x + y;
* }));
* // => a Promise of 76
*/
function spread(func) {
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
return function(array) {
return func.apply(this, array);
};
}
return spread;
});

View File

@@ -1,4 +1,4 @@
define(['./debounce', '../lang/isFunction', '../lang/isObject'], function(debounce, isFunction, isObject) {
define(['./debounce', '../lang/isObject'], function(debounce, isObject) {
/** Used as the `TypeError` message for "Functions" methods. */
var FUNC_ERROR_TEXT = 'Expected a function';
@@ -29,7 +29,7 @@ define(['./debounce', '../lang/isFunction', '../lang/isObject'], function(deboun
* @memberOf _
* @category Function
* @param {Function} func The function to throttle.
* @param {number} wait The number of milliseconds to throttle invocations to.
* @param {number} [wait=0] The number of milliseconds to throttle invocations to.
* @param {Object} [options] The options object.
* @param {boolean} [options.leading=true] Specify invoking on the leading
* edge of the timeout.
@@ -42,8 +42,9 @@ define(['./debounce', '../lang/isFunction', '../lang/isObject'], function(deboun
* jQuery(window).on('scroll', _.throttle(updatePosition, 100));
*
* // invoke `renewToken` when the click event is fired, but not more than once every 5 minutes
* var throttled = _.throttle(renewToken, 300000, { 'trailing': false })
* jQuery('.interactive').on('click', throttled);
* jQuery('.interactive').on('click', _.throttle(renewToken, 300000, {
* 'trailing': false
* }));
*
* // cancel a trailing throttled call
* jQuery(window).on('popstate', throttled.cancel);
@@ -52,7 +53,7 @@ define(['./debounce', '../lang/isFunction', '../lang/isObject'], function(deboun
var leading = true,
trailing = true;
if (!isFunction(func)) {
if (typeof func != 'function') {
throw new TypeError(FUNC_ERROR_TEXT);
}
if (options === false) {

View File

@@ -1,4 +1,4 @@
define([], function() {
define(['./baseCreate', './baseLodash'], function(baseCreate, baseLodash) {
/** Used as references for `-Infinity` and `Infinity`. */
var POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
@@ -10,15 +10,18 @@ define([], function() {
* @param {*} value The value to wrap.
*/
function LazyWrapper(value) {
this.actions = null;
this.dir = 1;
this.dropCount = 0;
this.filtered = false;
this.iteratees = null;
this.takeCount = POSITIVE_INFINITY;
this.views = null;
this.wrapped = value;
this.__wrapped__ = value;
this.__actions__ = null;
this.__dir__ = 1;
this.__dropCount__ = 0;
this.__filtered__ = false;
this.__iteratees__ = null;
this.__takeCount__ = POSITIVE_INFINITY;
this.__views__ = null;
}
LazyWrapper.prototype = baseCreate(baseLodash.prototype);
LazyWrapper.prototype.constructor = LazyWrapper;
return LazyWrapper;
});

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