Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.
github-actions[bot] edited this page Aug 11, 2023 · 10 revisions

Class: Limit

Hierarchy

  • AsyncQueue

    Limit

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Limit(rest, route)

Parameters

Name Type
rest Rest
route string

Overrides

AsyncQueue.constructor

Defined in

src/connections/Limit.ts:16

Properties

rateLimit

rateLimit: number

Defined in

src/connections/Limit.ts:14

Accessors

queued

get queued(): number

The amount of queued entries.

Seealso

remaining for the count with the head.

Returns

number

Inherited from

AsyncQueue.queued

Defined in

node_modules/@sapphire/async-queue/dist/index.d.ts:14


remaining

get remaining(): number

The amount of entries in the queue, including the head.

Seealso

queued for the queued count.

Returns

number

Inherited from

AsyncQueue.remaining

Defined in

node_modules/@sapphire/async-queue/dist/index.d.ts:9

Methods

abortAll

abortAll(): void

Aborts all the pending promises.

Note

To avoid race conditions, this does not unlock the head lock.

Returns

void

Inherited from

AsyncQueue.abortAll

Defined in

node_modules/@sapphire/async-queue/dist/index.d.ts:49


shift

shift(): void

Returns

void

Overrides

AsyncQueue.shift

Defined in

src/connections/Limit.ts:21


wait

wait(options?): Promise<void>

Waits for last promise and queues a new one

Example

const queue = new AsyncQueue();
async function request(url, options) {
    await queue.wait({ signal: options.signal });
    try {
        const result = await fetch(url, options);
        // Do some operations with 'result'
    } finally {
        // Remove first entry from the queue and resolve for the next entry
        queue.shift();
    }
}

request(someUrl1, someOptions1); // Will call fetch() immediately
request(someUrl2, someOptions2); // Will call fetch() after the first finished
request(someUrl3, someOptions3); // Will call fetch() after the second finished

Parameters

Name Type
options? Readonly<AsyncQueueWaitOptions>

Returns

Promise<void>

Inherited from

AsyncQueue.wait

Defined in

node_modules/@sapphire/async-queue/dist/index.d.ts:40

hue.ts

Clone this wiki locally