@ls-stack/utils 3.40.0 → 3.42.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.
Files changed (159) hide show
  1. package/dist/arrayUtils.d.cts +70 -57
  2. package/dist/arrayUtils.d.ts +70 -57
  3. package/dist/assertions.d.cts +128 -117
  4. package/dist/assertions.d.ts +128 -117
  5. package/dist/asyncQueue.cjs +117 -112
  6. package/dist/asyncQueue.d.cts +217 -215
  7. package/dist/asyncQueue.d.ts +217 -215
  8. package/dist/asyncQueue.js +117 -112
  9. package/dist/awaitDebounce.d.cts +26 -23
  10. package/dist/awaitDebounce.d.ts +26 -23
  11. package/dist/cache.cjs +2 -1
  12. package/dist/cache.d.cts +15 -9
  13. package/dist/cache.d.ts +15 -9
  14. package/dist/cache.js +2 -1
  15. package/dist/{chunk-ADM37GSC.js → chunk-7L4KCZJJ.js} +12 -10
  16. package/dist/{chunk-KW55OTUG.js → chunk-B3KFV2MH.js} +2 -2
  17. package/dist/chunk-GMJTLFM6.js +60 -0
  18. package/dist/{chunk-GHAQOUA6.js → chunk-Y45CE75W.js} +22 -1
  19. package/dist/concurrentCalls.d.cts +8 -4
  20. package/dist/concurrentCalls.d.ts +8 -4
  21. package/dist/concurrentCalls.js +1 -1
  22. package/dist/debounce.d.cts +12 -20
  23. package/dist/debounce.d.ts +12 -20
  24. package/dist/dedent.d.cts +31 -31
  25. package/dist/dedent.d.ts +31 -31
  26. package/dist/deepEqual.d.cts +10 -9
  27. package/dist/deepEqual.d.ts +10 -9
  28. package/dist/filterObjectOrArrayKeys.d.cts +44 -19
  29. package/dist/filterObjectOrArrayKeys.d.ts +44 -19
  30. package/dist/getAutoIncrementId.d.cts +25 -23
  31. package/dist/getAutoIncrementId.d.ts +25 -23
  32. package/dist/getCompositeKey.d.cts +2 -1
  33. package/dist/getCompositeKey.d.ts +2 -1
  34. package/dist/getValueStableKey.d.cts +4 -3
  35. package/dist/getValueStableKey.d.ts +4 -3
  36. package/dist/mutationUtils.d.cts +2 -2
  37. package/dist/mutationUtils.d.ts +2 -2
  38. package/dist/objUtils.cjs +51 -2
  39. package/dist/objUtils.d.cts +8 -3
  40. package/dist/objUtils.d.ts +8 -3
  41. package/dist/objUtils.js +11 -3
  42. package/dist/parallelAsyncCalls.cjs +2 -1
  43. package/dist/parallelAsyncCalls.d.cts +5 -4
  44. package/dist/parallelAsyncCalls.d.ts +5 -4
  45. package/dist/parallelAsyncCalls.js +2 -1
  46. package/dist/retryOnError.d.cts +23 -20
  47. package/dist/retryOnError.d.ts +23 -20
  48. package/dist/runShellCmd.d.cts +40 -40
  49. package/dist/runShellCmd.d.ts +40 -40
  50. package/dist/safeJson.d.cts +6 -2
  51. package/dist/safeJson.d.ts +6 -2
  52. package/dist/saferTyping.d.cts +21 -14
  53. package/dist/saferTyping.d.ts +21 -14
  54. package/dist/shallowEqual.d.cts +1 -1
  55. package/dist/shallowEqual.d.ts +1 -1
  56. package/dist/stringUtils.cjs +2 -2
  57. package/dist/stringUtils.d.cts +6 -7
  58. package/dist/stringUtils.d.ts +6 -7
  59. package/dist/stringUtils.js +1 -1
  60. package/dist/testUtils.cjs +11 -9
  61. package/dist/testUtils.d.cts +32 -14
  62. package/dist/testUtils.d.ts +32 -14
  63. package/dist/testUtils.js +4 -3
  64. package/dist/throttle.d.cts +57 -48
  65. package/dist/throttle.d.ts +57 -48
  66. package/dist/timers.d.cts +68 -63
  67. package/dist/timers.d.ts +68 -63
  68. package/dist/tsResult.d.cts +7 -6
  69. package/dist/tsResult.d.ts +7 -6
  70. package/dist/typeGuards.d.cts +65 -64
  71. package/dist/typeGuards.d.ts +65 -64
  72. package/dist/typeUtils.d.cts +18 -4
  73. package/dist/typeUtils.d.ts +18 -4
  74. package/dist/typedStrings.d.cts +68 -57
  75. package/dist/typedStrings.d.ts +68 -57
  76. package/dist/typingFnUtils.cjs +15 -0
  77. package/dist/typingFnUtils.d.cts +34 -7
  78. package/dist/typingFnUtils.d.ts +34 -7
  79. package/dist/typingFnUtils.js +18 -35
  80. package/dist/typingTestUtils.cjs +7 -1
  81. package/dist/typingTestUtils.d.cts +52 -11
  82. package/dist/typingTestUtils.d.ts +52 -11
  83. package/dist/typingTestUtils.js +7 -1
  84. package/dist/typingUtils.d.cts +4 -1
  85. package/dist/typingUtils.d.ts +4 -1
  86. package/dist/yamlStringify.cjs +11 -9
  87. package/dist/yamlStringify.js +2 -2
  88. package/package.json +5 -1
  89. package/docs/README.md +0 -72
  90. package/docs/_media/modules.md +0 -58
  91. package/docs/arrayUtils/-internal-.md +0 -179
  92. package/docs/arrayUtils/README.md +0 -550
  93. package/docs/assertions/-internal-.md +0 -63
  94. package/docs/assertions/README.md +0 -565
  95. package/docs/asyncQueue/-internal-.md +0 -297
  96. package/docs/asyncQueue/README.md +0 -1485
  97. package/docs/awaitDebounce.md +0 -66
  98. package/docs/cache/-internal-.md +0 -168
  99. package/docs/cache/README.md +0 -360
  100. package/docs/castValues.md +0 -47
  101. package/docs/concurrentCalls/-internal-.md +0 -490
  102. package/docs/concurrentCalls/README.md +0 -299
  103. package/docs/consoleFmt.md +0 -115
  104. package/docs/conversions.md +0 -27
  105. package/docs/createThrottleController/-internal-.md +0 -73
  106. package/docs/createThrottleController/README.md +0 -31
  107. package/docs/debounce.md +0 -188
  108. package/docs/dedent/-internal-.md +0 -17
  109. package/docs/dedent/README.md +0 -204
  110. package/docs/deepEqual.md +0 -94
  111. package/docs/enhancedMap.md +0 -358
  112. package/docs/exhaustiveMatch/-internal-.md +0 -39
  113. package/docs/exhaustiveMatch/README.md +0 -146
  114. package/docs/filterObjectOrArrayKeys.md +0 -109
  115. package/docs/getAutoIncrementId.md +0 -93
  116. package/docs/getCompositeKey.md +0 -39
  117. package/docs/getValueStableKey.md +0 -57
  118. package/docs/hash.md +0 -31
  119. package/docs/interpolate/-internal-.md +0 -61
  120. package/docs/interpolate/README.md +0 -62
  121. package/docs/keepPrevIfUnchanged.md +0 -43
  122. package/docs/levenshtein.md +0 -93
  123. package/docs/main.md +0 -21
  124. package/docs/mathUtils.md +0 -137
  125. package/docs/modules.md +0 -58
  126. package/docs/mutationUtils.md +0 -44
  127. package/docs/objUtils.md +0 -237
  128. package/docs/parallelAsyncCalls/-internal-.md +0 -347
  129. package/docs/parallelAsyncCalls/README.md +0 -45
  130. package/docs/promiseUtils/-internal-.md +0 -69
  131. package/docs/promiseUtils/README.md +0 -31
  132. package/docs/retryOnError/-internal-.md +0 -111
  133. package/docs/retryOnError/README.md +0 -168
  134. package/docs/runShellCmd/-internal-.md +0 -111
  135. package/docs/runShellCmd/README.md +0 -201
  136. package/docs/safeJson.md +0 -51
  137. package/docs/saferTyping.md +0 -228
  138. package/docs/serializeXML.md +0 -100
  139. package/docs/shallowEqual.md +0 -33
  140. package/docs/sleep.md +0 -27
  141. package/docs/stringUtils/-internal-.md +0 -17
  142. package/docs/stringUtils/README.md +0 -270
  143. package/docs/testUtils.md +0 -382
  144. package/docs/throttle/-internal-.md +0 -47
  145. package/docs/throttle/README.md +0 -178
  146. package/docs/time.md +0 -274
  147. package/docs/timers.md +0 -256
  148. package/docs/tsResult/-internal-.md +0 -327
  149. package/docs/tsResult/README.md +0 -702
  150. package/docs/typeGuards.md +0 -399
  151. package/docs/typeUtils/-internal-.md +0 -99
  152. package/docs/typeUtils/README.md +0 -195
  153. package/docs/typeUtils.typesTest.md +0 -7
  154. package/docs/typedStrings.md +0 -458
  155. package/docs/typingFnUtils/-internal-.md +0 -43
  156. package/docs/typingFnUtils/README.md +0 -317
  157. package/docs/typingTestUtils.md +0 -172
  158. package/docs/typingUtils.md +0 -135
  159. package/docs/yamlStringify.md +0 -83
@@ -2,18 +2,14 @@ import * as evtmitter from 'evtmitter';
2
2
  import { ResultValidErrors, Result } from 't-result';
3
3
  import { DurationObj } from './time.cjs';
4
4
 
5
- /**
6
- * Configuration for rate limiting task execution
7
- */
5
+ /** Configuration for rate limiting task execution */
8
6
  type RateLimit = {
9
7
  /** Maximum number of tasks to execute within the interval */
10
8
  maxTasks: number;
11
9
  /** Time interval in milliseconds or as a duration object */
12
10
  interval: DurationObj | number;
13
11
  };
14
- /**
15
- * Configuration options for AsyncQueue initialization
16
- */
12
+ /** Configuration options for AsyncQueue initialization */
17
13
  type AsyncQueueOptions = {
18
14
  /** Maximum number of tasks to run concurrently (default: 1) */
19
15
  concurrency?: number;
@@ -30,9 +26,7 @@ type AsyncQueueOptions = {
30
26
  /** Rate limit configuration to limit tasks per time interval */
31
27
  rateLimit?: RateLimit;
32
28
  };
33
- /**
34
- * Options for adding individual tasks to the queue
35
- */
29
+ /** Options for adding individual tasks to the queue */
36
30
  type AddOptions<I, T, E extends ResultValidErrors> = {
37
31
  /** AbortSignal to cancel this specific task */
38
32
  signal?: AbortSignal;
@@ -45,9 +39,7 @@ type AddOptions<I, T, E extends ResultValidErrors> = {
45
39
  /** Callback invoked when task fails */
46
40
  onError?: (error: E | Error) => void;
47
41
  };
48
- /**
49
- * Runtime context passed to task functions
50
- */
42
+ /** Runtime context passed to task functions */
51
43
  type RunCtx<I> = {
52
44
  /** Combined AbortSignal from task, queue, and timeout signals */
53
45
  signal?: AbortSignal;
@@ -57,88 +49,93 @@ type RunCtx<I> = {
57
49
  /**
58
50
  * A powerful async task queue with advanced error handling and flow control
59
51
  *
60
- * @template T - The type of value returned by successful tasks
61
- * @template E - The type of errors that tasks can produce (defaults to Error)
62
- * @template I - The type of metadata associated with tasks (defaults to unknown)
63
- *
64
- * @example Basic Usage
65
- * ```typescript
66
- * const queue = createAsyncQueue<string>({ concurrency: 2 });
52
+ * @example
53
+ * Basic Usage
54
+ * ```typescript
55
+ * const queue = createAsyncQueue<string>({ concurrency: 2 });
67
56
  *
68
- * const processedItems: string[] = [];
57
+ * const processedItems: string[] = [];
69
58
  *
70
- * queue.resultifyAdd(async () => {
59
+ * queue.resultifyAdd(async () => {
71
60
  * await delay(100);
72
61
  * return 'task completed';
73
- * }).then(result => {
62
+ * }).then(result => {
74
63
  * if (result.ok) processedItems.push(result.value);
75
- * });
64
+ * });
76
65
  *
77
- * await queue.onIdle();
78
- * console.log('Processed:', processedItems);
79
- * ```
66
+ * await queue.onIdle();
67
+ * console.log('Processed:', processedItems);
68
+ * ```
80
69
  *
81
- * @example Error Recovery
82
- * ```typescript
83
- * const queue = createAsyncQueue<string>({
70
+ * @example
71
+ * Error Recovery
72
+ * ```typescript
73
+ * const queue = createAsyncQueue<string>({
84
74
  * stopOnError: true,
85
75
  * rejectPendingOnError: false
86
- * });
76
+ * });
87
77
  *
88
- * // Add batch of tasks
89
- * const items = ['item1', 'item2', 'bad-item', 'item3'];
90
- * items.forEach(item => {
78
+ * // Add batch of tasks
79
+ * const items = ['item1', 'item2', 'bad-item', 'item3'];
80
+ * items.forEach(item => {
91
81
  * queue.resultifyAdd(async () => {
92
- * if (item === 'bad-item') throw new Error('Processing failed');
93
- * return item.toUpperCase();
82
+ * if (item === 'bad-item') throw new Error('Processing failed');
83
+ * return item.toUpperCase();
84
+ * });
94
85
  * });
95
- * });
96
86
  *
97
- * await queue.onIdle();
87
+ * await queue.onIdle();
98
88
  *
99
- * if (queue.isStopped) {
89
+ * if (queue.isStopped) {
100
90
  * console.log(`Stopped at ${queue.failed} failures, ${queue.size} remaining`);
101
91
  * // Reset and continue with remaining tasks
102
92
  * queue.reset();
103
93
  * await queue.onIdle();
104
- * }
105
- * ```
94
+ * }
95
+ * ```
96
+ *
97
+ * @example
98
+ * Lazy Start
99
+ * ```typescript
100
+ * const queue = createAsyncQueue<string>({ autoStart: false });
106
101
  *
107
- * @example Lazy Start
108
- * ```typescript
109
- * const queue = createAsyncQueue<string>({ autoStart: false });
102
+ * // Prepare all tasks without starting
103
+ * queue.resultifyAdd(() => processTask1());
104
+ * queue.resultifyAdd(() => processTask2());
105
+ * queue.resultifyAdd(() => processTask3());
110
106
  *
111
- * // Prepare all tasks without starting
112
- * queue.resultifyAdd(() => processTask1());
113
- * queue.resultifyAdd(() => processTask2());
114
- * queue.resultifyAdd(() => processTask3());
107
+ * // Start processing when ready
108
+ * queue.start();
109
+ * await queue.onIdle();
110
+ * ```
115
111
  *
116
- * // Start processing when ready
117
- * queue.start();
118
- * await queue.onIdle();
119
- * ```
112
+ * @template T - The type of value returned by successful tasks
113
+ * @template E - The type of errors that tasks can produce (defaults to Error)
114
+ * @template I - The type of metadata associated with tasks (defaults to
115
+ * unknown)
120
116
  */
121
117
  declare class AsyncQueue<T, E extends ResultValidErrors = Error, I = unknown> {
122
118
  #private;
123
119
  /**
124
120
  * Event emitter for tracking task lifecycle
125
121
  *
126
- * @example Listening to Events
127
- * ```typescript
128
- * const queue = createAsyncQueue<string>();
122
+ * @example
123
+ * Listening to Events
124
+ * ```typescript
125
+ * const queue = createAsyncQueue<string>();
129
126
  *
130
- * queue.events.on('start', (event) => {
127
+ * queue.events.on('start', (event) => {
131
128
  * console.log('Task started:', event.payload.meta);
132
- * });
129
+ * });
133
130
  *
134
- * queue.events.on('complete', (event) => {
131
+ * queue.events.on('complete', (event) => {
135
132
  * console.log('Task completed:', event.payload.value);
136
- * });
133
+ * });
137
134
  *
138
- * queue.events.on('error', (event) => {
135
+ * queue.events.on('error', (event) => {
139
136
  * console.error('Task failed:', event.payload.error);
140
- * });
141
- * ```
137
+ * });
138
+ * ```
142
139
  */
143
140
  events: evtmitter.Emitter<{
144
141
  /** Emitted when a task starts executing */
@@ -170,32 +167,33 @@ declare class AsyncQueue<T, E extends ResultValidErrors = Error, I = unknown> {
170
167
  /**
171
168
  * Add a task that returns a Result to the queue
172
169
  *
173
- * Use this method when your task function already returns a Result type.
174
- * For functions that throw errors or return plain values, use `resultifyAdd` instead.
170
+ * Use this method when your task function already returns a Result type. For
171
+ * functions that throw errors or return plain values, use `resultifyAdd`
172
+ * instead.
173
+ *
174
+ * @example
175
+ * ```typescript
176
+ * const queue = createAsyncQueue<string>();
177
+ *
178
+ * const result = await queue.add(async () => {
179
+ * try {
180
+ * const data = await fetchData();
181
+ * return Result.ok(data);
182
+ * } catch (error) {
183
+ * return Result.err(error);
184
+ * }
185
+ * });
186
+ *
187
+ * if (result.ok) {
188
+ * console.log('Success:', result.value);
189
+ * } else {
190
+ * console.log('Error:', result.error);
191
+ * }
192
+ * ```;
175
193
  *
176
194
  * @param fn - Task function that returns a Result
177
195
  * @param options - Optional configuration for this task
178
196
  * @returns Promise that resolves with the task result
179
- *
180
- * @example
181
- * ```typescript
182
- * const queue = createAsyncQueue<string>();
183
- *
184
- * const result = await queue.add(async () => {
185
- * try {
186
- * const data = await fetchData();
187
- * return Result.ok(data);
188
- * } catch (error) {
189
- * return Result.err(error);
190
- * }
191
- * });
192
- *
193
- * if (result.ok) {
194
- * console.log('Success:', result.value);
195
- * } else {
196
- * console.log('Error:', result.error);
197
- * }
198
- * ```
199
197
  */
200
198
  add(fn: (ctx: RunCtx<I>) => Promise<Result<T, E>> | Result<T, E>, options?: AddOptions<I, T, E>): Promise<Result<T, E | Error>>;
201
199
  /**
@@ -204,63 +202,68 @@ declare class AsyncQueue<T, E extends ResultValidErrors = Error, I = unknown> {
204
202
  * This is the most commonly used method. It automatically wraps your function
205
203
  * to handle errors and convert them to Result types.
206
204
  *
207
- * @param fn - Task function that returns a value or throws
208
- * @param options - Optional configuration for this task
209
- * @returns Promise that resolves with the task result wrapped in Result
210
- *
211
- * @example Basic Usage
212
- * ```typescript
213
- * const queue = createAsyncQueue<string>();
205
+ * @example
206
+ * Basic Usage
207
+ * ```typescript
208
+ * const queue = createAsyncQueue<string>();
214
209
  *
215
- * queue.resultifyAdd(async () => {
210
+ * queue.resultifyAdd(async () => {
216
211
  * const response = await fetch('/api/data');
217
212
  * return response.json();
218
- * }).then(result => {
213
+ * }).then(result => {
219
214
  * if (result.ok) {
220
- * console.log('Data:', result.value);
215
+ * console.log('Data:', result.value);
221
216
  * } else {
222
- * console.error('Failed:', result.error);
217
+ * console.error('Failed:', result.error);
223
218
  * }
224
- * });
225
- * ```
219
+ * });
220
+ * ```
226
221
  *
227
- * @example With Callbacks
228
- * ```typescript
229
- * queue.resultifyAdd(
222
+ * @example
223
+ * With Callbacks
224
+ * ```typescript
225
+ * queue.resultifyAdd(
230
226
  * async () => processData(),
231
227
  * {
232
- * onComplete: (data) => console.log('Processed:', data),
233
- * onError: (error) => console.error('Failed:', error),
234
- * timeout: 5000
228
+ * onComplete: (data) => console.log('Processed:', data),
229
+ * onError: (error) => console.error('Failed:', error),
230
+ * timeout: 5000
235
231
  * }
236
- * );
237
- * ```
232
+ * );
233
+ * ```
234
+ *
235
+ * @param fn - Task function that returns a value or throws
236
+ * @param options - Optional configuration for this task
237
+ * @returns Promise that resolves with the task result wrapped in Result
238
238
  */
239
239
  resultifyAdd(fn: (ctx: RunCtx<I>) => Promise<T> | T, options?: AddOptions<I, T, E>): Promise<Result<T, E | Error>>;
240
240
  /**
241
- * Wait for the queue to become idle (no pending tasks, no queued tasks, and no rate-limit timers)
241
+ * Wait for the queue to become idle (no pending tasks, no queued tasks, and
242
+ * no rate-limit timers)
242
243
  *
243
244
  * This method resolves when:
245
+ *
244
246
  * - All tasks have completed (success or failure)
245
247
  * - The queue is stopped due to error (stopOnError), even with remaining tasks
246
- * - There are no queued tasks, no running tasks, and no pending rate-limit timers
247
- *
248
- * @returns Promise that resolves when the queue is idle
248
+ * - There are no queued tasks, no running tasks, and no pending rate-limit
249
+ * timers
249
250
  *
250
251
  * @example
251
- * ```typescript
252
- * const queue = createAsyncQueue<string>();
252
+ * ```typescript
253
+ * const queue = createAsyncQueue<string>();
253
254
  *
254
- * // Add multiple tasks
255
- * for (let i = 0; i < 10; i++) {
255
+ * // Add multiple tasks
256
+ * for (let i = 0; i < 10; i++) {
256
257
  * queue.resultifyAdd(async () => `task ${i}`);
257
- * }
258
+ * }
258
259
  *
259
- * // Wait for all tasks to complete
260
- * await queue.onIdle();
260
+ * // Wait for all tasks to complete
261
+ * await queue.onIdle();
262
+ *
263
+ * console.log(`Completed: ${queue.completed}, Failed: ${queue.failed}`);
264
+ * ```
261
265
  *
262
- * console.log(`Completed: ${queue.completed}, Failed: ${queue.failed}`);
263
- * ```
266
+ * @returns Promise that resolves when the queue is idle
264
267
  */
265
268
  onIdle(): Promise<void>;
266
269
  /**
@@ -276,24 +279,24 @@ declare class AsyncQueue<T, E extends ResultValidErrors = Error, I = unknown> {
276
279
  /**
277
280
  * Clear all queued tasks (does not affect currently running tasks)
278
281
  *
279
- * This removes all tasks waiting in the queue but allows currently
280
- * executing tasks to complete normally.
282
+ * This removes all tasks waiting in the queue but allows currently executing
283
+ * tasks to complete normally.
281
284
  *
282
285
  * @example
283
- * ```typescript
284
- * const queue = createAsyncQueue({ concurrency: 1 });
286
+ * ```typescript
287
+ * const queue = createAsyncQueue({ concurrency: 1 });
285
288
  *
286
- * // Add multiple tasks
287
- * queue.resultifyAdd(async () => longRunningTask()); // Will start immediately
288
- * queue.resultifyAdd(async () => task2()); // Queued
289
- * queue.resultifyAdd(async () => task3()); // Queued
289
+ * // Add multiple tasks
290
+ * queue.resultifyAdd(async () => longRunningTask()); // Will start immediately
291
+ * queue.resultifyAdd(async () => task2()); // Queued
292
+ * queue.resultifyAdd(async () => task3()); // Queued
290
293
  *
291
- * // Clear remaining queued tasks
292
- * queue.clear();
294
+ * // Clear remaining queued tasks
295
+ * queue.clear();
293
296
  *
294
- * // Only the first task will complete
295
- * await queue.onIdle();
296
- * ```
297
+ * // Only the first task will complete
298
+ * await queue.onIdle();
299
+ * ```;
297
300
  */
298
301
  clear(): void;
299
302
  /** Number of tasks that have completed successfully */
@@ -308,66 +311,64 @@ declare class AsyncQueue<T, E extends ResultValidErrors = Error, I = unknown> {
308
311
  * Manually start processing tasks (only needed if autoStart: false)
309
312
  *
310
313
  * @example
311
- * ```typescript
312
- * const queue = createAsyncQueue({ autoStart: false });
314
+ * ```typescript
315
+ * const queue = createAsyncQueue({ autoStart: false });
313
316
  *
314
- * // Add tasks without starting processing
315
- * queue.resultifyAdd(async () => 'task1');
316
- * queue.resultifyAdd(async () => 'task2');
317
+ * // Add tasks without starting processing
318
+ * queue.resultifyAdd(async () => 'task1');
319
+ * queue.resultifyAdd(async () => 'task2');
317
320
  *
318
- * // Start processing when ready
319
- * queue.start();
320
- * await queue.onIdle();
321
- * ```
321
+ * // Start processing when ready
322
+ * queue.start();
323
+ * await queue.onIdle();
324
+ * ```;
322
325
  */
323
326
  start(): void;
324
327
  /**
325
328
  * Pause processing new tasks (currently running tasks continue)
326
329
  *
327
330
  * @example
328
- * ```typescript
329
- * const queue = createAsyncQueue();
331
+ * ```typescript
332
+ * const queue = createAsyncQueue();
330
333
  *
331
- * // Start some tasks
332
- * queue.resultifyAdd(async () => longRunningTask1());
333
- * queue.resultifyAdd(async () => longRunningTask2());
334
+ * // Start some tasks
335
+ * queue.resultifyAdd(async () => longRunningTask1());
336
+ * queue.resultifyAdd(async () => longRunningTask2());
334
337
  *
335
- * // Pause before more tasks are picked up
336
- * queue.pause();
338
+ * // Pause before more tasks are picked up
339
+ * queue.pause();
337
340
  *
338
- * // Later, resume processing
339
- * queue.resume();
340
- * ```
341
+ * // Later, resume processing
342
+ * queue.resume();
343
+ * ```;
341
344
  */
342
345
  pause(): void;
343
- /**
344
- * Resume processing tasks after pause
345
- */
346
+ /** Resume processing tasks after pause */
346
347
  resume(): void;
347
348
  /**
348
349
  * Reset the queue after being stopped, allowing new tasks to be processed
349
350
  *
350
- * This clears the stopped state and error reason, and resumes processing
351
- * any remaining queued tasks if autoStart was enabled.
351
+ * This clears the stopped state and error reason, and resumes processing any
352
+ * remaining queued tasks if autoStart was enabled.
352
353
  *
353
354
  * @example
354
- * ```typescript
355
- * const queue = createAsyncQueue({ stopOnError: true });
355
+ * ```typescript
356
+ * const queue = createAsyncQueue({ stopOnError: true });
356
357
  *
357
- * // Add tasks that will cause the queue to stop
358
- * queue.resultifyAdd(async () => { throw new Error('fail'); });
359
- * queue.resultifyAdd(async () => 'remaining task');
358
+ * // Add tasks that will cause the queue to stop
359
+ * queue.resultifyAdd(async () => { throw new Error('fail'); });
360
+ * queue.resultifyAdd(async () => 'remaining task');
360
361
  *
361
- * await queue.onIdle();
362
+ * await queue.onIdle();
362
363
  *
363
- * if (queue.isStopped) {
364
+ * if (queue.isStopped) {
364
365
  * console.log(`Queue stopped, ${queue.size} tasks remaining`);
365
366
  *
366
367
  * // Reset and process remaining tasks
367
368
  * queue.reset();
368
369
  * await queue.onIdle();
369
- * }
370
- * ```
370
+ * }
371
+ * ```
371
372
  */
372
373
  reset(): void;
373
374
  /** Whether the queue is stopped due to an error */
@@ -379,9 +380,7 @@ declare class AsyncQueue<T, E extends ResultValidErrors = Error, I = unknown> {
379
380
  /** The error that caused the queue to stop (if any) */
380
381
  get stoppedReason(): Error | undefined;
381
382
  }
382
- /**
383
- * AddOptions variant that requires metadata to be provided
384
- */
383
+ /** AddOptions variant that requires metadata to be provided */
385
384
  type AddOptionsWithId<I, T, E extends ResultValidErrors> = Omit<AddOptions<I, T, E>, 'meta'> & {
386
385
  meta: I;
387
386
  };
@@ -391,29 +390,29 @@ type AddOptionsWithId<I, T, E extends ResultValidErrors> = Omit<AddOptions<I, T,
391
390
  * This class enforces that every task must include metadata, which is useful
392
391
  * when you need to track or identify tasks consistently.
393
392
  *
394
- * @template T - The type of value returned by successful tasks
395
- * @template I - The type of metadata (required for all tasks)
396
- * @template E - The type of errors that tasks can produce
397
- *
398
393
  * @example
399
- * ```typescript
400
- * interface TaskMeta {
394
+ * ```typescript
395
+ * interface TaskMeta {
401
396
  * id: string;
402
397
  * priority: number;
403
- * }
398
+ * }
404
399
  *
405
- * const queue = createAsyncQueueWithMeta<string, TaskMeta>({ concurrency: 2 });
400
+ * const queue = createAsyncQueueWithMeta<string, TaskMeta>({ concurrency: 2 });
406
401
  *
407
- * queue.resultifyAdd(
402
+ * queue.resultifyAdd(
408
403
  * async () => processImportantTask(),
409
404
  * { meta: { id: 'task-1', priority: 1 } }
410
- * );
405
+ * );
411
406
  *
412
- * // Listen to events with metadata
413
- * queue.events.on('complete', (event) => {
407
+ * // Listen to events with metadata
408
+ * queue.events.on('complete', (event) => {
414
409
  * console.log(`Task ${event.payload.meta.id} completed`);
415
- * });
416
- * ```
410
+ * });
411
+ * ```
412
+ *
413
+ * @template T - The type of value returned by successful tasks
414
+ * @template I - The type of metadata (required for all tasks)
415
+ * @template E - The type of errors that tasks can produce
417
416
  */
418
417
  declare class AsyncQueueWithMeta<T, I, E extends ResultValidErrors = Error> extends AsyncQueue<T, E, I> {
419
418
  constructor(options?: AsyncQueueOptions);
@@ -423,63 +422,66 @@ declare class AsyncQueueWithMeta<T, I, E extends ResultValidErrors = Error> exte
423
422
  /**
424
423
  * Create a new AsyncQueue instance
425
424
  *
426
- * @template T - The type of value returned by successful tasks
427
- * @template E - The type of errors that tasks can produce (defaults to Error)
428
- * @param options - Configuration options for the queue
429
- * @returns A new AsyncQueue instance
430
- *
431
- * @example Basic Queue
432
- * ```typescript
433
- * const queue = createAsyncQueue<string>({ concurrency: 3 });
434
- * ```
425
+ * @example
426
+ * Basic Queue
427
+ * ```typescript
428
+ * const queue = createAsyncQueue<string>({ concurrency: 3 });
429
+ * ```
435
430
  *
436
- * @example Error Handling Queue
437
- * ```typescript
438
- * const queue = createAsyncQueue<string>({
431
+ * @example
432
+ * Error Handling Queue
433
+ * ```typescript
434
+ * const queue = createAsyncQueue<string>({
439
435
  * concurrency: 2,
440
436
  * stopOnError: true,
441
437
  * rejectPendingOnError: true
442
- * });
443
- * ```
438
+ * });
439
+ * ```
444
440
  *
445
- * @example Lazy Start Queue
446
- * ```typescript
447
- * const queue = createAsyncQueue<string>({
441
+ * @example
442
+ * Lazy Start Queue
443
+ * ```typescript
444
+ * const queue = createAsyncQueue<string>({
448
445
  * autoStart: false,
449
446
  * concurrency: 1
450
- * });
451
- * ```
447
+ * });
448
+ * ```
449
+ *
450
+ * @template T - The type of value returned by successful tasks
451
+ * @template E - The type of errors that tasks can produce (defaults to Error)
452
+ * @param options - Configuration options for the queue
453
+ * @returns A new AsyncQueue instance
452
454
  */
453
455
  declare function createAsyncQueue<T, E extends ResultValidErrors = Error>(options?: AsyncQueueOptions): AsyncQueue<T, E>;
454
456
 
455
457
  /**
456
458
  * Create a new AsyncQueueWithMeta instance that requires metadata for all tasks
457
459
  *
458
- * @template T - The type of value returned by successful tasks
459
- * @template I - The type of metadata (required for all tasks)
460
- * @template E - The type of errors that tasks can produce (defaults to Error)
461
- * @param options - Configuration options for the queue
462
- * @returns A new AsyncQueueWithMeta instance
463
- *
464
460
  * @example
465
- * ```typescript
466
- * interface TaskInfo {
461
+ * ```typescript
462
+ * interface TaskInfo {
467
463
  * taskId: string;
468
464
  * userId: string;
469
- * }
465
+ * }
470
466
  *
471
- * const queue = createAsyncQueueWithMeta<ProcessResult, TaskInfo>({
467
+ * const queue = createAsyncQueueWithMeta<ProcessResult, TaskInfo>({
472
468
  * concurrency: 5
473
- * });
469
+ * });
474
470
  *
475
- * queue.resultifyAdd(
471
+ * queue.resultifyAdd(
476
472
  * async (ctx) => {
477
- * console.log(`Processing task ${ctx.meta.taskId} for user ${ctx.meta.userId}`);
478
- * return await processUserTask(ctx.meta.userId);
473
+ * console.log(`Processing task ${ctx.meta.taskId} for user ${ctx.meta.userId}`);
474
+ * return await processUserTask(ctx.meta.userId);
479
475
  * },
480
476
  * { meta: { taskId: '123', userId: 'user456' } }
481
- * );
482
- * ```
477
+ * );
478
+ * ```
479
+ *
480
+ * @template T - The type of value returned by successful tasks
481
+ * @template I - The type of metadata (required for all tasks)
482
+ * @template E - The type of errors that tasks can produce (defaults to Error)
483
+ * @param options - Configuration options for the queue
484
+ * @returns A new AsyncQueueWithMeta instance
483
485
  */
484
486
  declare function createAsyncQueueWithMeta<T, I, E extends ResultValidErrors = Error>(options?: AsyncQueueOptions): AsyncQueueWithMeta<T, I, E>;
485
487