mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 17:47:49 +00:00
Use _.restParam in _.sortByAll.
This commit is contained in:
@@ -7325,25 +7325,16 @@
|
|||||||
* _.map(_.sortByAll(users, ['user', 'age']), _.values);
|
* _.map(_.sortByAll(users, ['user', 'age']), _.values);
|
||||||
* // => [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]]
|
* // => [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]]
|
||||||
*/
|
*/
|
||||||
function sortByAll() {
|
var sortByAll = restParam(function(collection, args) {
|
||||||
var args = arguments,
|
|
||||||
collection = args[0],
|
|
||||||
guard = args[3],
|
|
||||||
index = 0,
|
|
||||||
length = args.length - 1;
|
|
||||||
|
|
||||||
if (collection == null) {
|
if (collection == null) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
var props = Array(length);
|
var guard = args[2];
|
||||||
while (index < length) {
|
if (guard && isIterateeCall(args[0], args[1], guard)) {
|
||||||
props[index] = args[++index];
|
args = args[0];
|
||||||
}
|
}
|
||||||
if (guard && isIterateeCall(args[1], args[2], guard)) {
|
return baseSortByOrder(collection, baseFlatten(args), []);
|
||||||
props = args[1];
|
});
|
||||||
}
|
|
||||||
return baseSortByOrder(collection, baseFlatten(props), []);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is like `_.sortByAll` except that it allows specifying the
|
* This method is like `_.sortByAll` except that it allows specifying the
|
||||||
|
|||||||
Reference in New Issue
Block a user