1.1.0 • Published 8 years ago

incremental-average v1.1.0

Weekly downloads
98
License
MIT
Repository
github
Last release
8 years ago

incremental-average

I use this library to help me deal with incremental averaging

How to use

Install

Regular npm install

npm install incremental-average --save

Use

incrementalAverage will return an object that has the following interface:

  • add() - will receive one or many numbers as parameters, add them tot he average, and will return the average.
  • getAverage() - will return the average
  • getIncrement() - will return the n position of the last incremented number
import incrementalAverage from 'incremental-average'
 
const ia = incrementalAverage();

const averageOfOneToFive = ia.add(1,2,3,4,5); // 3
const averageOfOneToTen = ia.add(6,7,8,9,10); // 5.5

Alternative use

import incrementalAverage from 'incremental-average'
 
const ia = incrementalAverage(1,2,3,4,5);

const averageOfOneToFive = ia.getAverage(); // 3
const averageOfOneToTen = ia.add(6,7,8,9,10); // 5.5