-
Notifications
You must be signed in to change notification settings - Fork 1
Limit
-
AsyncQueue
↳
Limit
• new Limit(rest
, route
)
Name | Type |
---|---|
rest |
Rest |
route |
string |
AsyncQueue.constructor
• rateLimit: number
• get
queued(): number
The amount of queued entries.
Seealso
remaining for the count with the head.
number
AsyncQueue.queued
node_modules/@sapphire/async-queue/dist/index.d.ts:14
• get
remaining(): number
The amount of entries in the queue, including the head.
Seealso
queued for the queued count.
number
AsyncQueue.remaining
node_modules/@sapphire/async-queue/dist/index.d.ts:9
▸ abortAll(): void
Aborts all the pending promises.
Note
To avoid race conditions, this does not unlock the head lock.
void
AsyncQueue.abortAll
node_modules/@sapphire/async-queue/dist/index.d.ts:49
▸ shift(): void
void
AsyncQueue.shift
▸ 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
Name | Type |
---|---|
options? |
Readonly <AsyncQueueWaitOptions > |
Promise
<void
>
AsyncQueue.wait
node_modules/@sapphire/async-queue/dist/index.d.ts:40