fn-call-streak
v0.1.1
Published
Make sure a function gets called regularly.
Downloads
2
Maintainers
Readme
fn-call-streak
Make sure a function gets called regularly.
Installing
npm install fn-call-streak
Usage
Let's assume you want to detect a series of calls to f
, in which each call must happen within 10ms.
const streak = require('fn-call-streak')
const check = streak(10) // threshold of 10ms
const f = () => {
const isFirst = check()
if (isFirst) console.log('first call in streak!')
}
You can pass an optional total duration of the series as a second parameter.
Look at the tests to find more examples.
Contributing
If you have a question, found a bug or want to propose a feature, have a look at the issues page.