No Description

countBy.js 372B

123456789101112
  1. define(['./_group', './_has'], function (_group, _has) {
  2. // Counts instances of an object that group by a certain criterion. Pass
  3. // either a string attribute to count by, or a function that returns the
  4. // criterion.
  5. var countBy = _group(function(result, value, key) {
  6. if (_has(result, key)) result[key]++; else result[key] = 1;
  7. });
  8. return countBy;
  9. });