Adding the ability to _.groupBy(list, 'account_id')

This commit is contained in:
Jeremy Ashkenas
2011-10-21 14:44:38 -04:00
parent 00cd88cfa6
commit 96fdf6fbac
2 changed files with 10 additions and 2 deletions

View File

@@ -202,6 +202,12 @@ $(document).ready(function() {
var parity = _.groupBy([1, 2, 3, 4, 5, 6], function(num){ return num % 2; });
ok('0' in parity && '1' in parity, 'created a group for each value');
equals(parity[0].join(', '), '2, 4, 6', 'put each even number in the right group');
var list = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten"];
var grouped = _.groupBy(list, 'length');
equals(grouped['3'].join(' '), 'one two six ten');
equals(grouped['4'].join(' '), 'four five nine');
equals(grouped['5'].join(' '), 'three seven eight');
});
test('collections: sortedIndex', function() {