Package Exports
- running-average
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (running-average) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
running-average

Memory-efficient module that accepts an unlimited quantity of numbers and returns the average of the most recent n numbers
Install
$ npm install --save running-averageUsage
var RunningAverage = require('running-average');
// create an instance
var runningAverage = new RunningAverage({
windowSize: 4 // how many recent numbers to consider when calculating average (default is 100)
});
// push a number
runningAverage.push(1);
// or a few numbers
runningAverage.push(2, 3, 4);
// get the current average any time you want
runningAverage.getAverage(); // => 2.5
// add some more numbers
runningAverage.push(4,4,4,4);
// get an updated average (which only takes into account the last `windowSize` numbers)
runningAverage.getAverage(); // => 4
// oh, and it's chainable too!
runningAverage.push(1).push(3).getAverage(); // => 3License
MIT © Nathan Friedly