Skip to content

derhuerst/fn-call-streak

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Make sure a function gets called regularly.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published