
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
data-sample
Advanced tools
Sometimes you need to continuously sample data into fixed sized buckets.
data-sample will call a sampler function a set number of times at a set interval (in milliseconds) and will return a data bucket when done. At this point it will call itself and run recursively forever.
A sampler is a function with 2 methods: .next() which acquires the next sample and .dump() which returns the sample bucket.
sample(sampleCount, sampleRate, samplerFn, callbackFn)
The following example will collect samples every second and return a 10 sample bucket every 10 seconds.
const sample = require('data-sample')
const testSampler = () => {
let bucket = []
return {
next: () => bucket.push(bucket.length + 1),
dump: () => bucket,
}
}
sample(10, 1000, sampler, console.log)
setInterval is unreliable so the nanotimer library is used to address this. The library is not super performant and consumes way too much CPU when running fast (eg 100ms). This should be replaced with more efficient code.FAQs
Continuously sample data into fixed sized buckets
The npm package data-sample receives a total of 3 weekly downloads. As such, data-sample popularity was classified as not popular.
We found that data-sample 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

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.