Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

average-array-objects

1.0.0 • Public • Published

Simple calculation of average values for an array of objects.
Note: used Array.prototype.includes() and Number.isFinite().

Install

$ npm i average-array-objects --save

Usage

import getAverages from 'average-array-objects';
 
const rows = [
    { id: 1, a: 456, b: 635, c: 682 },
    { id: 2, a: 100, b: 99, c: 33 },
    { id: 3, a: 283, b: 238, c: 123 },
];
 
const result = getAverages(rows, ['id']);
// ==> {"a":279.6666666666667,"b":324,"c":279.3333333333333}

License

MIT

Install

npm i average-array-objects

DownloadsWeekly Downloads

3

Version

1.0.0

License

MIT

Last publish

Collaborators

  • avatar