
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
Maintaining a simple dynamic rolling average.
The rolling average is the unweighted mean of the previous i numbers where i is the length or argument of the rolling average.
Install with npm:
$ npm install --save srol
let srol = require('srol');
To create a rolling average of length n use:
let rollingAverage = new srol(n);
To add a number, or an array of numbers, to the rolling average use:
rollingAverage.add(n);
add will throw a TypeError if n is not a number or an array containing not a number.
Getter that returns the average of the last rollingAverage.length numbers.
rollingAverage.average;
Simple example or test of the rolling average.
let rollingAverage = new srol(3);
rollingAverage.add(5);
Since there is only 1 number in the array, the average will be 5.
rollingAverage.add(4);
rollingAverage.add(6);
Now the array is 'full' and the average will be 5, (4+5+6)/3.
rollingAverage.add(7);
The first number, 5, is replaced by a 7 and the average becomes 6.
> rollingAverage.average;
6
Test cover the basic function and requirements of the rolling average.
$ npm install && npm test
Pull requests are always welcome.
FAQs
Class maintaining a rolling average.
We found that srol demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.