https://github.com/zephyrpersonal/rate-limiting
generating a counter by rules and trigger when reach the limit
https://github.com/zephyrpersonal/rate-limiting
counter rate-limit rate-limiting
Last synced: 3 months ago
JSON representation
generating a counter by rules and trigger when reach the limit
- Host: GitHub
- URL: https://github.com/zephyrpersonal/rate-limiting
- Owner: zephyrpersonal
- Created: 2018-03-06T08:24:54.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-03-06T09:04:47.000Z (over 8 years ago)
- Last Synced: 2025-03-05T01:35:39.061Z (over 1 year ago)
- Topics: counter, rate-limit, rate-limiting
- Language: JavaScript
- Size: 1000 Bytes
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RATE-LIMITING
## simple counter fires callback when reach limit
```bash
npm install rate-limiting-counter -S
```
```js
const Counter = require('rate-limiting-counter')
const counter = new Counter({
interval: 1000 // every seconds to reset inner count,
max: 100 // max count in one loop,
onReachLimit: () => {} // callback when hit limit in one loop,
autoStart: true // if start the counter loop when constructor has called
})
counter.add() // add 1 to inner count
counter.stop() // stop counter
counter.resume() // resume counter
```