mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 10:27:49 +00:00
in groupBy, also pass index to iterator.
This commit is contained in:
@@ -254,8 +254,8 @@
|
|||||||
// Groups the object's values by a criterion produced by an iterator
|
// Groups the object's values by a criterion produced by an iterator
|
||||||
_.groupBy = function(obj, iterator) {
|
_.groupBy = function(obj, iterator) {
|
||||||
var result = {};
|
var result = {};
|
||||||
each(obj, function(value) {
|
each(obj, function(value, index) {
|
||||||
var key = iterator(value);
|
var key = iterator(value, index);
|
||||||
(result[key] || (result[key] = [])).push(value)
|
(result[key] || (result[key] = [])).push(value)
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user