https://github.com/iphands/event-horizon
Eats things that happen too many times per time window. A time window in this case is a sliding window.
https://github.com/iphands/event-horizon
Last synced: 4 months ago
JSON representation
Eats things that happen too many times per time window. A time window in this case is a sliding window.
- Host: GitHub
- URL: https://github.com/iphands/event-horizon
- Owner: iphands
- Created: 2015-10-08T22:00:39.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-10-20T14:53:06.000Z (almost 11 years ago)
- Last Synced: 2026-03-30T23:51:52.899Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 492 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

# event-horizon
[npm-url]: https://npmjs.org/package/event-horizon
[downloads-image]: http://img.shields.io/npm/dm/event-horizon.svg
[npm-image]: http://img.shields.io/npm/v/event-horizon.svg
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url]
Eats things that happen too many times per time window.
A time window in this case is a sliding window.
# Example
## Simple
```javascript
var horizon = require('event-horizon').instance({window: 200, max: 50});
horizon.run(function () {
request(...);
});
```
## With a callback
```javascript
var horizon = require('event-horizon').instance({window: 200, max: 50});
horizon.run(function () {
request(...);
}, function () {
deferred.reject();
});
```