3.0.0 • Published 10 months ago

limit-io v3.0.0

Weekly downloads
17
License
MIT
Repository
github
Last release
10 months ago

LIMIT-IO - This is a simple query limiter based on memory storage

Features

  • Two operating modes
  • Support ESM
  • Simple

Installation

Node.js 18.0.0 or newer is required

  • Using npm (recommended)
    	```bash
    	npm i limit-io
    	```
  • Using Yarn
    yarn add limit-io
  • Using pnpm
    pnpm add limit-io

API Reference

TimeoutLimiter

import { TimeoutLimiter } from 'limit-io';

Constructor

Initializing a new instance

const limiter = new TimeoutLimiter(recoveryInterval, amount)
ParameterTypeDescription
recoveryIntervalstringAPI ms
amountnumberNumber of available requests

limit

Returns the limit on the number of calls

limiter.limit; // => number

amount

Returns the number of available calls

limiter.amount; // => number

recoveryTime

Returns the time to restore

limiter.recoveryTime; // => number

recoveryInterval

Returns the interval for the reset of requests

limiter.recoveryInterval; // => number

accept

Checks if there are enough calls to call

limiter.accept(amount); // => boolean
ParameterTypeDescription
amountnumberNumber of requests requested

reset

Clears the number of available calls

limiter.reset();

FireLimiter

The difference from Limiter is that it will be called as soon as there is enough for the specified number of calls

3.0.0

10 months ago

2.0.0

6 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago