Skip to content
This repository was archived by the owner on Apr 15, 2025. It is now read-only.

Commit 6e800cc

Browse files
author
williamd5
committed
update docs
1 parent f8174ac commit 6e800cc

File tree

2 files changed

+48
-24
lines changed

2 files changed

+48
-24
lines changed

README.md

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ If you want to reset the rate limit after a successful login, call [`rateLimit.r
3939
<summary>Table of contents</summary>
4040

4141
- [Class: `RateLimit`](#class-ratelimit)
42-
- [Static method: `RateLimit.attempt(name, source, [attempts])`](#static-method-ratelimitattemptname-source-attempts)
43-
- [Static method: `RateLimit.check(name, source)`](#static-method-ratelimitcheckname-source)
42+
- [Static method: `RateLimit.attempt(name, source, [attempts], [callback])`](#static-method-ratelimitattemptname-source-attempts-callback)
43+
- [Static method: `RateLimit.check(name, source, [callback])`](#static-method-ratelimitcheckname-source-callbac)
4444
- [Static method: `RateLimit.clear(name)`](#static-method-ratelimitclearname)
4545
- [Static method: `RateLimit.create(name, limit, timeWindow)`](#static-method-ratelimitcreatename-limit-timewindow)
4646
- [Static method: `RateLimit.delete(name)`](#static-method-ratelimitdeletename)
4747
- [Static method: `RateLimit.get(name)`](#static-method-ratelimitgetname)
4848
- [Static method: `RateLimit.reset(name, source)`](#static-method-ratelimitresetname-source)
4949
- [Static method: `RateLimit.setRemaining(name, source, remaining)`](#static-method-ratelimitsetremainingname-source-remaining)
5050
- [`new RateLimit(name, limit, timeWindow)`](#new-ratelimitname-limit-timewindow)
51-
- [`rateLimit.attempt(source, [attempts])`](#ratelimitattemptsource-attempts)
52-
- [`rateLimit.check(source)`](#ratelimitchecksource)
51+
- [`rateLimit.attempt(source, [attempts], [callback])`](#ratelimitattemptsource-attempts-callback)
52+
- [`rateLimit.check(source, [callback])`](#ratelimitchecksource-callback)
5353
- [`rateLimit.clear()`](#ratelimitclear)
5454
- [`rateLimit.delete()`](#ratelimitdelete)
5555
- [`rateLimit.limit`](#ratelimitlimit)
@@ -69,22 +69,28 @@ If you want to reset the rate limit after a successful login, call [`rateLimit.r
6969
## Class: `RateLimit`
7070
Rate limit
7171

72-
<a name="static-method-ratelimitattemptname-source-attempts"></a>
73-
### Static method: `RateLimit.attempt(name, source, [attempts])`
72+
<a name="static-method-ratelimitattemptname-source-attempts-callback"></a>
73+
### Static method: `RateLimit.attempt(name, source, [attempts], [callback])`
7474
Make an attempt with a source ID
7575

7676
- `name` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The name of the rate limit
7777
- `source` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) Unique source identifier (e.g. username, IP, etc.)
7878
- `attempts` [`number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) The number of attempts to make. Default: `1`
79+
- `callback` [`function`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function) Callback function. Default: `undefined`
80+
- `result` [`AttemptResult`](#interface-attemptresult) The result of the attempt
81+
- Returns: [`void`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Undefined_type)
7982
- Returns: [`AttemptResult`](#interface-attemptresult)
8083
- Throws: [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) If the rate limit does not exist
8184

82-
<a name="static-method-ratelimitcheckname-source"></a>
83-
### Static method: `RateLimit.check(name, source)`
85+
<a name="static-method-ratelimitcheckname-source-callbac"></a>
86+
### Static method: `RateLimit.check(name, source, [callback])`
8487
Check the attempt state for a source ID without decrementing the remaining attempts
8588

8689
- `name` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The name of the rate limit
8790
- `source` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) Unique source identifier (e.g. username, IP, etc.)
91+
- `callback` [`function`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function) Callback function. Default: `undefined`
92+
- `result` [`AttemptResult`](#interface-attemptresult) The result of the attempt
93+
- Returns: [`void`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Undefined_type)
8894
- Returns: [`AttemptResult`](#interface-attemptresult)
8995
- Throws: [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) If the rate limit does not exist
9096

@@ -150,19 +156,25 @@ Create a new rate limit
150156
- `timeWindow` [`number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) The time window in seconds (e.g. 60)
151157
- Throws: [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) If the rate limit already exists
152158

153-
<a name="ratelimitattemptsource-attempts"></a>
154-
### `rateLimit.attempt(source, [attempts])`
159+
<a name="ratelimitattemptsource-attempts-callback"></a>
160+
### `rateLimit.attempt(source, [attempts], [callback])`
155161
Make an attempt with a source ID
156162

157163
- `source` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) Unique source identifier (e.g. username, IP, etc.)
158164
- `attempts` [`number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) The number of attempts to make. Default: `1`
165+
- `callback` [`function`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function) Callback function
166+
- `result` [`AttemptResult`](#interface-attemptresult) The result of the attempt
167+
- Returns: [`void`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Undefined_type)
159168
- Returns: [`AttemptResult`](#interface-attemptresult)
160169

161-
<a name="ratelimitchecksource"></a>
162-
### `rateLimit.check(source)`
170+
<a name="ratelimitchecksource-callback"></a>
171+
### `rateLimit.check(source, [callback])`
163172
Check the attempt state for a source ID without decrementing the remaining attempts
164173

165174
- `source` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) Unique source identifier (e.g. username, IP, etc.)
175+
- `callback` [`function`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function) Callback function
176+
- `result` [`AttemptResult`](#interface-attemptresult) The result of the attempt
177+
- Returns: [`void`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Undefined_type)
166178
- Returns: [`AttemptResult`](#interface-attemptresult)
167179

168180
<a name="ratelimitclear"></a>

README.template.md

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ If you want to reset the rate limit after a successful login, call [`rateLimit.r
3939
<summary>Table of contents</summary>
4040

4141
- [Class: `RateLimit`](#class-ratelimit)
42-
- [Static method: `RateLimit.attempt(name, source, [attempts])`](#static-method-ratelimitattemptname-source-attempts)
43-
- [Static method: `RateLimit.check(name, source)`](#static-method-ratelimitcheckname-source)
42+
- [Static method: `RateLimit.attempt(name, source, [attempts], [callback])`](#static-method-ratelimitattemptname-source-attempts-callback)
43+
- [Static method: `RateLimit.check(name, source, [callback])`](#static-method-ratelimitcheckname-source-callbac)
4444
- [Static method: `RateLimit.clear(name)`](#static-method-ratelimitclearname)
4545
- [Static method: `RateLimit.create(name, limit, timeWindow)`](#static-method-ratelimitcreatename-limit-timewindow)
4646
- [Static method: `RateLimit.delete(name)`](#static-method-ratelimitdeletename)
4747
- [Static method: `RateLimit.get(name)`](#static-method-ratelimitgetname)
4848
- [Static method: `RateLimit.reset(name, source)`](#static-method-ratelimitresetname-source)
4949
- [Static method: `RateLimit.setRemaining(name, source, remaining)`](#static-method-ratelimitsetremainingname-source-remaining)
5050
- [`new RateLimit(name, limit, timeWindow)`](#new-ratelimitname-limit-timewindow)
51-
- [`rateLimit.attempt(source, [attempts])`](#ratelimitattemptsource-attempts)
52-
- [`rateLimit.check(source)`](#ratelimitchecksource)
51+
- [`rateLimit.attempt(source, [attempts], [callback])`](#ratelimitattemptsource-attempts-callback)
52+
- [`rateLimit.check(source, [callback])`](#ratelimitchecksource-callback)
5353
- [`rateLimit.clear()`](#ratelimitclear)
5454
- [`rateLimit.delete()`](#ratelimitdelete)
5555
- [`rateLimit.limit`](#ratelimitlimit)
@@ -69,22 +69,28 @@ If you want to reset the rate limit after a successful login, call [`rateLimit.r
6969
## Class: `RateLimit`
7070
Rate limit
7171

72-
<a name="static-method-ratelimitattemptname-source-attempts"></a>
73-
### Static method: `RateLimit.attempt(name, source, [attempts])`
72+
<a name="static-method-ratelimitattemptname-source-attempts-callback"></a>
73+
### Static method: `RateLimit.attempt(name, source, [attempts], [callback])`
7474
Make an attempt with a source ID
7575

7676
- `name` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The name of the rate limit
7777
- `source` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) Unique source identifier (e.g. username, IP, etc.)
7878
- `attempts` [`number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) The number of attempts to make. Default: `1`
79+
- `callback` [`function`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function) Callback function. Default: `undefined`
80+
- `result` [`AttemptResult`](#interface-attemptresult) The result of the attempt
81+
- Returns: [`void`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Undefined_type)
7982
- Returns: [`AttemptResult`](#interface-attemptresult)
8083
- Throws: [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) If the rate limit does not exist
8184

82-
<a name="static-method-ratelimitcheckname-source"></a>
83-
### Static method: `RateLimit.check(name, source)`
85+
<a name="static-method-ratelimitcheckname-source-callbac"></a>
86+
### Static method: `RateLimit.check(name, source, [callback])`
8487
Check the attempt state for a source ID without decrementing the remaining attempts
8588

8689
- `name` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) The name of the rate limit
8790
- `source` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) Unique source identifier (e.g. username, IP, etc.)
91+
- `callback` [`function`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function) Callback function. Default: `undefined`
92+
- `result` [`AttemptResult`](#interface-attemptresult) The result of the attempt
93+
- Returns: [`void`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Undefined_type)
8894
- Returns: [`AttemptResult`](#interface-attemptresult)
8995
- Throws: [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) If the rate limit does not exist
9096

@@ -150,19 +156,25 @@ Create a new rate limit
150156
- `timeWindow` [`number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) The time window in seconds (e.g. 60)
151157
- Throws: [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error) If the rate limit already exists
152158

153-
<a name="ratelimitattemptsource-attempts"></a>
154-
### `rateLimit.attempt(source, [attempts])`
159+
<a name="ratelimitattemptsource-attempts-callback"></a>
160+
### `rateLimit.attempt(source, [attempts], [callback])`
155161
Make an attempt with a source ID
156162

157163
- `source` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) Unique source identifier (e.g. username, IP, etc.)
158164
- `attempts` [`number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) The number of attempts to make. Default: `1`
165+
- `callback` [`function`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function) Callback function
166+
- `result` [`AttemptResult`](#interface-attemptresult) The result of the attempt
167+
- Returns: [`void`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Undefined_type)
159168
- Returns: [`AttemptResult`](#interface-attemptresult)
160169

161-
<a name="ratelimitchecksource"></a>
162-
### `rateLimit.check(source)`
170+
<a name="ratelimitchecksource-callback"></a>
171+
### `rateLimit.check(source, [callback])`
163172
Check the attempt state for a source ID without decrementing the remaining attempts
164173

165174
- `source` [`string`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) Unique source identifier (e.g. username, IP, etc.)
175+
- `callback` [`function`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function) Callback function
176+
- `result` [`AttemptResult`](#interface-attemptresult) The result of the attempt
177+
- Returns: [`void`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Undefined_type)
166178
- Returns: [`AttemptResult`](#interface-attemptresult)
167179

168180
<a name="ratelimitclear"></a>

0 commit comments

Comments
 (0)