0.1.1 • Published 5 years ago

fn-call-streak v0.1.1

Weekly downloads
4
License
ISC
Repository
github
Last release
5 years ago

fn-call-streak

Make sure a function gets called regularly.

npm version build status dependency status dev dependency status ISC-licensed chat on gitter support me on Patreon

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.