aggregate-functions

1.0.1 • Public • Published

aggregate-functions

JavaScript library to get aggregate values of array, namely; SUM, AVG, MAX, MIN, COUNT.

Node.js (Install)

Requirements:

  • Node.js

  • npm (Node.js package manager)

 
npm i aggregate-functions
 
Or
 
npm i aggregate-functions --save
 

Usage

Modular include:

 
const  aggregateFunctions = require("aggregate-functions");
 

Use in method

 
//for getting SUM of an array
let sum = aggregateFunctions.sum(array);
 
 //for getting AVG of an array
let avg = aggregateFunctions.avg(array);
 
 //for getting MAX of an array
let max = aggregateFunctions.max(array);
 
 //for getting MIN of an array
let min = aggregateFunctions.min(array);
 
 //for getting COUNT/LENGTH of an array
let count = aggregateFunctions.count(array);
 

### SOME EXAMPLES

    let exapmpleArray = [7, 20, 24, 14, 2, 19, 12]
 
    //for getting SUM of an array
    let sum = aggregateFunctions.sum(exapmpleArray);
    console.log(sum);//98
 
    //for getting AVG of an array
    let avg = aggregateFunctions.avg(exapmpleArray);
    console.log(avg);//14
 
    //for getting MAX of an array
    let max = aggregateFunctions.max(exapmpleArray);
    console.log(max);//24
 
    //for getting MIN of an array
    let min = aggregateFunctions.min(exapmpleArray);
    console.log(min);//2
 
    //for getting COUNT/LENGTH of an array
    let count = aggregateFunctions.count(exapmpleArray);
    console.log(count);//7  

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i aggregate-functions

      Weekly Downloads

      3

      Version

      1.0.1

      License

      ISC

      Unpacked Size

      5.48 kB

      Total Files

      3

      Last publish

      Collaborators

      • tapanhk2