
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
flow-rolling-stats
Advanced tools
This Javascript library provides rolling time series operators for unevenly spaced data, such as simple moving averages (SMAs), exponential moving averages (EMAs), and various rolling functions. It is based on the utsAlgorithms C library.
The implementation details are described in "Algorithms for Unevenly Spaced Time Series: Moving Averages and Other Rolling Operators", Eckner (2017).
npm install flow-rolling-stats
npm test: Run test suitenpm start: Run npm run build in watch modenpm run test:watch: Run test suite in interactive watch modenpm run test:prod: Run linting and generate coveragenpm run build: Generate bundles and typings, create docsnpm run lint: Lints codenpm run commit: Commit using conventional commit style (husky will tell you to use it if you haven't)Operators are implemented as Javascript classes with a standard interface and designed to be used in real-time processing pipeline where observations are received periodically at uneven time intervals.
Typical usage is shown below (where RollingMean can be replaced with any of the supported operator classes):
const windowedAvg1 = new RollingMean({
windowSize: { duration: 15, unit: 'minutes' }
});
const windowedAvg2 = new RollingMean({
windowSize: { duration: 15, unit: 'minutes' }
});
// Process an event as it arrives
on('event', event => {
// Construct metric
const metric = {
timestamp: event.timestamp;
avgValue1: windowedAvg1.update(event.value1, event.timestamp);
avgValue2: windowedAvg2.update(event.value2, event.timestamp);
};
// Send metric to next stage of pipeline
emit(metric);
});
| Class | Operation | Comments |
|---|---|---|
RollingCount | Count of observations in window | |
RollingMin | Min value of observations in window | |
RollingMax | Max value of observations in window | |
RollingMean | Arithmetic mean of observations in window | |
RollingSum | Sum of observations in window | |
SmaLast | Simple moving average using last value | |
SmaNext | Simple moving average using next value | |
SmaLinear | Simple moving average using linear interpolation | |
EmaLast | Exponentially-weighted average using last value | |
EmaNext | Exponentially-weighted average using next value | |
EmaLinear | Exponentially-weighted average using linear interpolation |
Window size is specified when constructing an operator class. Supported time units are:
msmillisecondssecond(s) -minute(s)hour(s)days(s)Call the update method of an operation to record a new observation. Pass the observation value and timestamp (in epoch milliseconds) as parameters. The update method returns the calculated statistic after the window has been updated.
Note that value property returns the calculated statistic and can be called at any time without performing a window update.
Many of the operators maintain a sum that is updated over the lifetime of the operator. To maintain numerical stability and negate the effects of limited floating point precision the method of Kahan (1965)[1] is used to perform compensated addition.
[1] Kahan, W. (1965). Further remarks on reducing truncation errors Communications of the ACM 8 (1), 40.
FAQs
Rolling time series operators for unevenly spaced data
We found that flow-rolling-stats 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.