# @types/lambda-rate-limiter

> TypeScript definitions for lambda-rate-limiter

Latest version **3.0.2** (published 2023-11-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install @types/lambda-rate-limiter
pnpm add @types/lambda-rate-limiter
yarn add @types/lambda-rate-limiter
bun add @types/lambda-rate-limiter
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2023-11-07 |
| First published | 2021-11-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 51449 |
| Maintainers | types |

## Links

- npm: https://www.npmjs.com/package/@types/lambda-rate-limiter
- Repository: https://github.com/DefinitelyTyped/DefinitelyTyped
- Homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/lambda-rate-limiter
- npm.io page: https://npm.io/package/@types/lambda-rate-limiter

## Recent versions

- 3.0.2 (latest) — 2023-11-07
- 3.0.0 (ts3.7) — 2021-11-03
- 3.0.1 — 2023-10-18

## README

# Installation
> `npm install --save @types/lambda-rate-limiter`

# Summary
This package contains type definitions for lambda-rate-limiter (https://github.com/blackflux/lambda-rate-limiter).

# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/lambda-rate-limiter.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/lambda-rate-limiter/index.d.ts)
````ts
export = rateLimiterFactory;

/**
 * Initializes the rate limiter.
 *
 * @example
 * import limiterFactory = require('lambda-rate-limiter');
 *
 * const limiter = limiterFactory({
 *   interval: 60000,
 *   uniqueTokenPerInterval: 500,
 * });
 *
 * limiter
 *   .check(10, 'USER_TOKEN') // define maximum of 10 requests per interval
 *   .catch(() => {
 *     // rate limit exceeded: 429
 *   })
 *   .then(() => {
 *     // ok
 *   });
 */
declare function rateLimiterFactory(options?: rateLimiterFactory.Options): rateLimiterFactory.RateLimiter;

declare namespace rateLimiterFactory {
    interface Options {
        /**
         * Rate limit interval in ms, starts on first request.
         *
         * @default 60000
         */
        interval?: number | undefined;
        /**
         * Max unique tokens per interval. Excess causes earliest seen to drop, per instantiation.
         *
         * @default 500
         */
        uniqueTokenPerInterval?: number | undefined;
    }

    interface RateLimiter {
        /**
         * Check whether rate limit was reached.
         *
         * @param limit Max requests per interval.
         * @param token Any token value. Could be the user ip or login.
         */
        check(limit: number, token: string): Promise<number>;
    }
}

````

### Additional Details
 * Last updated: Tue, 07 Nov 2023 09:09:38 GMT
 * Dependencies: none

# Credits
These definitions were written by [BendingBender](https://github.com/bendingbender).

---
_Source: https://npm.io/package/@types/lambda-rate-limiter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
