Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -335,8 +335,13 @@ | |
|
||
// Groups the object's values by a criterion. Pass either a string attribute | ||
// to group by, or a function that returns the criterion. | ||
_.groupBy = function(obj, value, context) { | ||
_.groupBy = function(obj, value, dict, context) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
jdalton
|
||
if (!_.isBoolean(dict)) { | ||
context = dict; | ||
dict = false; | ||
} | ||
return group(obj, value, context, function(result, key, value) { | ||
if (dict) return result[key] = value; | ||
(_.has(result, key) ? result[key] : (result[key] = [])).push(value); | ||
}); | ||
}; | ||
|
This has been brought up before as another api (see #1064 & #1008).