1.0.2 • Published 9 years ago

count-by v1.0.2

Weekly downloads
2
License
MIT
Repository
-
Last release
9 years ago

count-by.js

Utility function to count number of arbitrary object properties in a list

Install

npm install count-by

Usage

var countBy = require('count-by');
var orders = [
  { id: 1, user: { name: 'Alice' } }
, { id: 2, user: { name: 'Bob' } }
, { id: 3, user: { name: 'Eve' } }
, { id: 4, user: { name: 'Alice' } }
];
var names = countBy(orders, 'user.name');
// { Alice: 2, Bob: 1, Eve: 1 }

License

MIT