|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
376 bytes
|
| Line | |
|---|
| 1 | var _group = require('./_group.js');
|
|---|
| 2 | var _has = require('./_has.js');
|
|---|
| 3 |
|
|---|
| 4 | // Counts instances of an object that group by a certain criterion. Pass
|
|---|
| 5 | // either a string attribute to count by, or a function that returns the
|
|---|
| 6 | // criterion.
|
|---|
| 7 | var countBy = _group(function(result, value, key) {
|
|---|
| 8 | if (_has(result, key)) result[key]++; else result[key] = 1;
|
|---|
| 9 | });
|
|---|
| 10 |
|
|---|
| 11 | module.exports = countBy;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.