(breaking change) moving _.reduce's method signature to that of ECMA5. _.reduce(obj, iterator, memo). Updated tests and docs.

This commit is contained in:
Jeremy Ashkenas
2010-07-15 09:50:55 -04:00
parent e81a2ec516
commit 9827f87611
4 changed files with 28 additions and 22 deletions

View File

@@ -12,11 +12,11 @@ $(document).ready(function() {
var counts = _(lyrics).chain()
.map(function(line) { return line.split(''); })
.flatten()
.reduce({}, function(hash, l) {
.reduce(function(hash, l) {
hash[l] = hash[l] || 0;
hash[l]++;
return hash;
}).value();
}, {}).value();
ok(counts['a'] == 16 && counts['e'] == 10, 'counted all the letters in the song');
});