@sapphire/async-queue 1.4.0 → 1.4.1-next.63e15eb.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,2 +1,45 @@
1
- export * from './lib/AsyncQueue';
2
- //# sourceMappingURL=index.d.ts.map
1
+ /**
2
+ * The AsyncQueue class used to sequentialize burst requests
3
+ */
4
+ declare class AsyncQueue {
5
+ /**
6
+ * The remaining amount of queued promises
7
+ */
8
+ get remaining(): number;
9
+ /**
10
+ * The promises array
11
+ */
12
+ private promises;
13
+ /**
14
+ * Waits for last promise and queues a new one
15
+ * @example
16
+ * ```typescript
17
+ * const queue = new AsyncQueue();
18
+ * async function request(url, options) {
19
+ * await queue.wait({ signal: options.signal });
20
+ * try {
21
+ * const result = await fetch(url, options);
22
+ * // Do some operations with 'result'
23
+ * } finally {
24
+ * // Remove first entry from the queue and resolve for the next entry
25
+ * queue.shift();
26
+ * }
27
+ * }
28
+ *
29
+ * request(someUrl1, someOptions1); // Will call fetch() immediately
30
+ * request(someUrl2, someOptions2); // Will call fetch() after the first finished
31
+ * request(someUrl3, someOptions3); // Will call fetch() after the second finished
32
+ * ```
33
+ */
34
+ wait(options?: Readonly<AsyncQueueWaitOptions>): Promise<void>;
35
+ /**
36
+ * Unlocks the head lock and transfers the next lock (if any) to the head.
37
+ * @returns Whether or not there was an element pending to process.
38
+ */
39
+ shift(): void;
40
+ }
41
+ interface AsyncQueueWaitOptions {
42
+ signal?: AbortSignal | undefined | null;
43
+ }
44
+
45
+ export { AsyncQueue, AsyncQueueWaitOptions };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sapphire/async-queue",
3
- "version": "1.4.0",
3
+ "version": "1.4.1-next.63e15eb.0",
4
4
  "description": "Sequential asynchronous lock-based queue for promises",
5
5
  "author": "@sapphire",
6
6
  "license": "MIT",
@@ -19,7 +19,7 @@
19
19
  "scripts": {
20
20
  "test": "vitest run",
21
21
  "lint": "eslint src tests --ext ts --fix -c ../../.eslintrc",
22
- "build": "tsup && tsc -b src",
22
+ "build": "tsup",
23
23
  "prepack": "yarn build",
24
24
  "bump": "cliff-jumper",
25
25
  "check-update": "cliff-jumper --dry-run"
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
@@ -1,45 +0,0 @@
1
- /// <reference types="node" />
2
- /**
3
- * The AsyncQueue class used to sequentialize burst requests
4
- */
5
- export declare class AsyncQueue {
6
- /**
7
- * The remaining amount of queued promises
8
- */
9
- get remaining(): number;
10
- /**
11
- * The promises array
12
- */
13
- private promises;
14
- /**
15
- * Waits for last promise and queues a new one
16
- * @example
17
- * ```typescript
18
- * const queue = new AsyncQueue();
19
- * async function request(url, options) {
20
- * await queue.wait({ signal: options.signal });
21
- * try {
22
- * const result = await fetch(url, options);
23
- * // Do some operations with 'result'
24
- * } finally {
25
- * // Remove first entry from the queue and resolve for the next entry
26
- * queue.shift();
27
- * }
28
- * }
29
- *
30
- * request(someUrl1, someOptions1); // Will call fetch() immediately
31
- * request(someUrl2, someOptions2); // Will call fetch() after the first finished
32
- * request(someUrl3, someOptions3); // Will call fetch() after the second finished
33
- * ```
34
- */
35
- wait(options?: Readonly<AsyncQueueWaitOptions>): Promise<void>;
36
- /**
37
- * Unlocks the head lock and transfers the next lock (if any) to the head.
38
- * @returns Whether or not there was an element pending to process.
39
- */
40
- shift(): void;
41
- }
42
- export interface AsyncQueueWaitOptions {
43
- signal?: AbortSignal | undefined | null;
44
- }
45
- //# sourceMappingURL=AsyncQueue.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AsyncQueue.d.ts","sourceRoot":"","sources":["../../src/lib/AsyncQueue.ts"],"names":[],"mappings":";AAEA;;GAEG;AACH,qBAAa,UAAU;IACtB;;OAEG;IACH,IAAW,SAAS,IAAI,MAAM,CAE7B;IAED;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAyB;IAEzC;;;;;;;;;;;;;;;;;;;;OAoBG;IACI,IAAI,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,qBAAqB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAarE;;;OAGG;IACI,KAAK,IAAI,IAAI;CAapB;AAED,MAAM,WAAW,qBAAqB;IACrC,MAAM,CAAC,EAAE,WAAW,GAAG,SAAS,GAAG,IAAI,CAAC;CACxC"}
@@ -1,17 +0,0 @@
1
- /// <reference types="node" />
2
- import type { AsyncQueue } from './AsyncQueue';
3
- /**
4
- * @internal
5
- */
6
- export declare class AsyncQueueEntry {
7
- readonly promise: Promise<void>;
8
- private resolve;
9
- private reject;
10
- private readonly queue;
11
- private signal;
12
- private signalListener;
13
- constructor(queue: AsyncQueue);
14
- setSignal(signal: AbortSignal): this;
15
- use(): this;
16
- }
17
- //# sourceMappingURL=AsyncQueueEntry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AsyncQueueEntry.d.ts","sourceRoot":"","sources":["../../src/lib/AsyncQueueEntry.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C;;GAEG;AACH,qBAAa,eAAe;IAC3B,SAAgB,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;IACnC,OAAO,CAAC,MAAM,CAAoC;IAClD,OAAO,CAAC,cAAc,CAA6B;gBAEhC,KAAK,EAAE,UAAU;IAQ7B,SAAS,CAAC,MAAM,EAAE,WAAW;IAc7B,GAAG;CAUV"}