fn-call-streak

0.1.1 • Public • Published

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.

Package Sidebar

Install

npm i fn-call-streak

Weekly Downloads

1

Version

0.1.1

License

ISC

Unpacked Size

3.46 kB

Total Files

4

Last publish

Collaborators

  • derhuerst