Skip to content

naimsulejmani/aggregate.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

##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

How to install

npm i aggregate_groupby_js

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();

About

Aggregate Functions for javascript Object

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published