Skip to content

Commit

Permalink
Merge pull request jashkenas#1601 from braddunbar/argument-order
Browse files Browse the repository at this point in the history
Swap argument order to match convention.
  • Loading branch information
jashkenas committed Apr 23, 2014
2 parents af62a21 + 2a1d74a commit b28197b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions underscore.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,28 +326,28 @@
iterator = lookupIterator(iterator, context);
_.each(obj, function(value, index) {
var key = iterator(value, index, obj);
behavior(result, key, value);
behavior(result, value, key);
});
return result;
};
};

// Groups the object's values by a criterion. Pass either a string attribute
// to group by, or a function that returns the criterion.
_.groupBy = group(function(result, key, value) {
_.groupBy = group(function(result, value, key) {
_.has(result, key) ? result[key].push(value) : result[key] = [value];
});

// Indexes the object's values by a criterion, similar to `groupBy`, but for
// when you know that your index values will be unique.
_.indexBy = group(function(result, key, value) {
_.indexBy = group(function(result, value, key) {
result[key] = value;
});

// Counts instances of an object that group by a certain criterion. Pass
// either a string attribute to count by, or a function that returns the
// criterion.
_.countBy = group(function(result, key) {
_.countBy = group(function(result, value, key) {
_.has(result, key) ? result[key]++ : result[key] = 1;
});

Expand Down

0 comments on commit b28197b

Please sign in to comment.