Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

countBy.js 372B

123456789101112
  1. define(['./_has', './_group'], function (_has, _group) {
  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. });