Basic usage

Given an array of objects and an identity callback function to determine how each object should be identified. Returns an object where the keys are the id values the callback returned and each value is an integer telling how many times that id occurred.

import { counting } from 'radash'

const gods = [{
  name: 'Ra',
  culture: 'egypt'
}, {
  name: 'Zeus',
  culture: 'greek'
}, {
  name: 'Loki',
  culture: 'greek'

counting(gods, g => g.culture) // => { egypt: 1, greek: 2 }


This _.counting function is 100% covered by tests. See them and contribute at GitHub.


See the source for _.counting on GitHub.