Skip to content
Wraps a function to limit the amount of times it can be called, then calls the a notifier function once that limit has been reached.
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
test
.gitignore
README.md
index.js
package.json

README.md

Behave

Behave wraps a function to limit the amount of times it can be called, then calls the notifier function once that limit has been reached.

npm tag

Usage

var behave = require('behave');

var myfunc = behave(5, function() {
  console.log('Hello');
}, function() {
  console.log('Good bye');
});

for (var i = 0; i < 20; i++) {
  myfunc();
}

The above example will print.

Hello
Hello
Hello
Hello
Hello
Good Bye
Something went wrong with that request. Please try again.