/event-horizon

Primary LanguageJavaScript

event-horizon

NPM version Downloads

Eats things that happen too many times per time window. A time window in this case is a sliding window.

Example

Simple

var horizon = require('event-horizon').instance({window: 200, max: 50});
horizon.run(function () {
    request(...);
});

With a callback

var horizon = require('event-horizon').instance({window: 200, max: 50});
horizon.run(function () {
    request(...);
}, function () {
    deferred.reject();
});