Meet npm Pro: unlimited public & private packages + package-based permissions.Learn more »

aggregate_groupby_js

1.0.11 • Public • Published

##aggregate.js The javascript library for using aggregate functions on array of objects.

Basic functions like SUM, MIN, MAX, AVG, DISTINCT_COUNT for entire javascript objects

Example:

var arr = [
                        {"shape":"square","color":"red","used":1,"instances":1},
                        {"shape":"square","color":"red","used":2,"instances":1},
                        {"shape":"circle","color":"blue","used":0,"instances":0},
                        {"shape":"square","color":"blue","used":4,"instances":4},
                        {"shape":"circle","color":"red","used":1,"instances":1},
                        {"shape":"circle","color":"red","used":1,"instances":0},
                        {"shape":"square","color":"blue","used":4,"instances":5},
                        {"shape":"square","color":"red","used":2,"instances":1}
                    ];
 

Specify columns

var columns =["used", "instances"];

Initialize object

var gb = new GroupBy(arr,columns);

or

var gb = new GroupBy(arr,["used", "instances"]);

Call the aggregate functions

gb.sum();
gb.min();
gb.max();
gb.avg();
gb.distinctCount();

Install

npm i aggregate_groupby_js

DownloadsWeekly Downloads

12

Version

1.0.11

License

ISC

Unpacked Size

6.74 kB

Total Files

5

Last publish

Collaborators

  • avatar