
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.
window-reduce
Advanced tools
apply a reduce function to a circular buffer.
I created this for performance monitoring, I need to make performance measurements, but do not require high precision measurements to be stored forever. For example, I want to keep a measure of bandwidth used per second, but I don't really need to track the bandwidth per second for the entire time the app has been running - the last 60 seconds is enough! It is useful to know the history of performance, but instead we could track the averages over the last hour at the precision of minutes, not seconds, and then the past few days at the precision of hours!
This means we can measure performance characteristics over a wide range of time spans without using much resources at all. This means we can add performance monitoring to our app without adversely effecting performance.
var stats = require('stats/mutable')
function id (item) { return item.ts }
function reduce (acc, item) {
return stats(acc, item.value)
}
var circular_reduce = require('circular-buffer-reduce')(id, reduce, 1000, 60)
var acc
//whenever something happens, apply the reduce function.
acc = circular_reduce(acc, {ts: Date.now(), value: Math.random()})
createCircularReduce returns a reduce function that aggregates incoming items
into max aggregations that are each width units wide. If you want to track
the last minute worth of seconds, and each item has a javascript timestamp
(in milliseconds) then width should be 1000, and max should be 60.
getTs is a function that returns the timestamp for the current item passed to
circular_reduce. reduce is a standard reduce function that takes the current
accumulator and the data item. since there is no option for a initial item,
reduce must accept reduce(null, item) as the first item in a new accumulation.
FAQs
apply a reduce function to a circular buffer.
We found that window-reduce 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.