# s-ratelimiter

> Ratelimits function calls by delaying them

Latest version **1.0.1** (published 2020-06-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install s-ratelimiter
pnpm add s-ratelimiter
yarn add s-ratelimiter
bun add s-ratelimiter
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2020-06-01 |
| First published | 2020-06-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | seymar |
| Maintainers | seymar |
| Keywords | ratelimit, rate, limit |

## Links

- npm: https://www.npmjs.com/package/s-ratelimiter
- Repository: https://github.com/seymar/s-ratelimiter
- Homepage: https://github.com/seymar/s-ratelimiter#readme
- Issues: https://github.com/seymar/s-ratelimiter/issues
- npm.io page: https://npm.io/package/s-ratelimiter

## Alternatives

- [promise-throttle](https://npm.io/package/promise-throttle.md) — 44.2K weekly downloads
- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2020-06-01
- 1.0.0 — 2020-06-01

## README

# s-ratelimiter
Ratelimits function calls by delaying them
* Allows for bursts of calls
* Simple lightweight implementation

# Example
```javascript
import { create_ratelimiter } from 's-ratelimiter'

const ratelimit = create_ratelimiter({
    amount: 1,
    period: 1000 // once/1000ms
})

function somefunction (n) {
    return new Promise((res, rej) => {
        setTimeout(() => {
            res(`fn ${n} done`)
        }, Math.random() * 100)
    })
}

for (let n = 0; n < 10; n++)
    ratelimit(() => {
        somefunction('A' + n)
        .then(console.log)
    })

```

---
_Source: https://npm.io/package/s-ratelimiter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
