@isdk/util 0.3.1 → 0.3.3

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 (55) hide show
  1. package/dist/index.d.mts +491 -1
  2. package/dist/index.d.ts +491 -1
  3. package/dist/index.js +1 -1
  4. package/dist/index.mjs +1 -1
  5. package/docs/classes/BinarySemaphore.md +418 -0
  6. package/docs/classes/ConfigFile.md +54 -5
  7. package/docs/classes/Deque.md +1912 -0
  8. package/docs/classes/IntSet.md +216 -0
  9. package/docs/classes/Semaphore.md +538 -0
  10. package/docs/classes/SignalGate.md +184 -0
  11. package/docs/functions/RateLimit.md +37 -0
  12. package/docs/functions/arrayHasAll.md +1 -1
  13. package/docs/functions/extNameLevel.md +1 -1
  14. package/docs/functions/filenameReservedRegex.md +1 -1
  15. package/docs/functions/findPort.md +25 -0
  16. package/docs/functions/getMultiLevelExtname.md +1 -1
  17. package/docs/functions/glob.md +1 -1
  18. package/docs/functions/isStringIn.md +1 -1
  19. package/docs/functions/isValidFilename.md +1 -1
  20. package/docs/functions/isValidFilepath.md +1 -1
  21. package/docs/functions/normalizeIncludeFiles.md +1 -1
  22. package/docs/functions/parseFrontMatter.md +1 -1
  23. package/docs/functions/parseYaml.md +1 -1
  24. package/docs/functions/reControlCharsRegex.md +1 -1
  25. package/docs/functions/registerYamlTag.md +2 -2
  26. package/docs/functions/removeLeadingEmptyLines.md +1 -1
  27. package/docs/functions/sanitizeFilename.md +1 -1
  28. package/docs/functions/sanitizeFilepath.md +1 -1
  29. package/docs/functions/sleep.md +36 -0
  30. package/docs/functions/stringifyYaml.md +1 -1
  31. package/docs/functions/toCamelCase.md +1 -1
  32. package/docs/functions/toCapitalCase.md +1 -1
  33. package/docs/functions/toPascalCase.md +1 -1
  34. package/docs/functions/traverseFolder.md +1 -1
  35. package/docs/functions/traverseFolderSync.md +1 -1
  36. package/docs/functions/yieldExec.md +27 -0
  37. package/docs/globals.md +17 -0
  38. package/docs/interfaces/BinarySemaphoreAcquireOptions.md +25 -0
  39. package/docs/interfaces/BinarySemaphoreOptions.md +57 -0
  40. package/docs/interfaces/BinarySemaphoreReleaseOptions.md +25 -0
  41. package/docs/interfaces/BinarySemaphoreReleaserFunc.md +37 -0
  42. package/docs/interfaces/IncludeFiles.md +3 -3
  43. package/docs/interfaces/LoadConfigFileOptions.md +3 -3
  44. package/docs/interfaces/SanitizeFilenameOptions.md +3 -3
  45. package/docs/interfaces/SemaphoreOptions.md +89 -0
  46. package/docs/interfaces/SemaphoreTaskItem.md +73 -0
  47. package/docs/type-aliases/SemaphoreIsReadyFuncType.md +15 -0
  48. package/docs/type-aliases/StringifyFunc.md +1 -1
  49. package/docs/type-aliases/TraverseFolderHandler.md +1 -1
  50. package/docs/type-aliases/TraverseFolderSyncHandler.md +1 -1
  51. package/docs/variables/DefaultAllTextFiles.md +1 -1
  52. package/docs/variables/DefaultAsyncSemaphoreCapacity.md +11 -0
  53. package/docs/variables/FilenameReservedRegex.md +1 -1
  54. package/docs/variables/WindowsReservedNameRegex.md +1 -1
  55. package/package.json +4 -2
@@ -0,0 +1,538 @@
1
+ [**@isdk/util**](../README.md)
2
+
3
+ ***
4
+
5
+ [@isdk/util](../globals.md) / Semaphore
6
+
7
+ # Class: Semaphore
8
+
9
+ Defined in: [src/async-semaphore.ts:372](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L372)
10
+
11
+ A Semaphore implementation for managing concurrency in asynchronous operations.
12
+ Semaphores allow a fixed number of resources to be accessed concurrently.
13
+ This class extends BinarySemaphore and adds support for a maximum concurrency limit and an optional readiness check.
14
+
15
+ Example usage:
16
+
17
+ ```typescript
18
+ const semaphore = new Semaphore(5); // Allows 5 concurrent operations.
19
+
20
+ const semaphore = new Semaphore(
21
+ 4, // Allow 4 concurrent async calls
22
+ {
23
+ capacity: 100, // Prealloc space for 100 tokens
24
+ isReadyFn: async () => {
25
+ // Check if the system is ready to handle more requests
26
+ return true;
27
+ },
28
+ pauseFn: () => {
29
+ console.log('Pausing the stream');
30
+ },
31
+ resumeFn: () => {
32
+ console.log('Resuming the stream');
33
+ }
34
+ }
35
+ );
36
+
37
+ async function fetchData(x) {
38
+ await semaphore.acquire()
39
+ try {
40
+ console.log(semaphore.pendingCount() + ' calls to fetch are waiting')
41
+ // ... do some async stuff with x
42
+ } finally {
43
+ semaphore.release();
44
+ }
45
+ }
46
+
47
+ const data = await Promise.all(array.map(fetchData));
48
+ ```
49
+
50
+ ## Extends
51
+
52
+ - [`BinarySemaphore`](BinarySemaphore.md)
53
+
54
+ ## Constructors
55
+
56
+ ### Constructor
57
+
58
+ > **new Semaphore**(`maxConcurrency`, `options`?): `Semaphore`
59
+
60
+ Defined in: [src/async-semaphore.ts:390](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L390)
61
+
62
+ Creates a semaphore object. The first argument is the maximum concurrently number and the second argument is optional.
63
+
64
+ #### Parameters
65
+
66
+ ##### maxConcurrency
67
+
68
+ The maximum number of callers allowed to acquire the semaphore concurrently.
69
+
70
+ `number` | [`SemaphoreOptions`](../interfaces/SemaphoreOptions.md)
71
+
72
+ ##### options?
73
+
74
+ [`SemaphoreOptions`](../interfaces/SemaphoreOptions.md)
75
+
76
+ #### Returns
77
+
78
+ `Semaphore`
79
+
80
+ #### Overrides
81
+
82
+ [`BinarySemaphore`](BinarySemaphore.md).[`constructor`](BinarySemaphore.md#constructor)
83
+
84
+ ## Properties
85
+
86
+ ### \_activeCount
87
+
88
+ > `protected` **\_activeCount**: `number`
89
+
90
+ Defined in: [src/async-semaphore.ts:97](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L97)
91
+
92
+ #### Inherited from
93
+
94
+ [`BinarySemaphore`](BinarySemaphore.md).[`_activeCount`](BinarySemaphore.md#_activecount)
95
+
96
+ ***
97
+
98
+ ### emitter
99
+
100
+ > `protected` **emitter**: `EventEmitter`
101
+
102
+ Defined in: [src/async-semaphore.ts:91](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L91)
103
+
104
+ #### Inherited from
105
+
106
+ [`BinarySemaphore`](BinarySemaphore.md).[`emitter`](BinarySemaphore.md#emitter)
107
+
108
+ ***
109
+
110
+ ### free
111
+
112
+ > `protected` **free**: [`Deque`](Deque.md)\<`any`\>
113
+
114
+ Defined in: [src/async-semaphore.ts:374](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L374)
115
+
116
+ #### Overrides
117
+
118
+ [`BinarySemaphore`](BinarySemaphore.md).[`free`](BinarySemaphore.md#free)
119
+
120
+ ***
121
+
122
+ ### initTokenFn()
123
+
124
+ > `protected` **initTokenFn**: (`token`?) => `void`
125
+
126
+ Defined in: [src/async-semaphore.ts:95](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L95)
127
+
128
+ #### Parameters
129
+
130
+ ##### token?
131
+
132
+ `any`
133
+
134
+ #### Returns
135
+
136
+ `void`
137
+
138
+ #### Inherited from
139
+
140
+ [`BinarySemaphore`](BinarySemaphore.md).[`initTokenFn`](BinarySemaphore.md#inittokenfn)
141
+
142
+ ***
143
+
144
+ ### maxConcurrency
145
+
146
+ > `readonly` **maxConcurrency**: `number`
147
+
148
+ Defined in: [src/async-semaphore.ts:373](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L373)
149
+
150
+ ***
151
+
152
+ ### paused
153
+
154
+ > `protected` **paused**: `boolean`
155
+
156
+ Defined in: [src/async-semaphore.ts:96](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L96)
157
+
158
+ #### Inherited from
159
+
160
+ [`BinarySemaphore`](BinarySemaphore.md).[`paused`](BinarySemaphore.md#paused)
161
+
162
+ ***
163
+
164
+ ### pauseFn()?
165
+
166
+ > `protected` `optional` **pauseFn**: () => `void`
167
+
168
+ Defined in: [src/async-semaphore.ts:93](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L93)
169
+
170
+ #### Returns
171
+
172
+ `void`
173
+
174
+ #### Inherited from
175
+
176
+ [`BinarySemaphore`](BinarySemaphore.md).[`pauseFn`](BinarySemaphore.md#pausefn)
177
+
178
+ ***
179
+
180
+ ### resumeFn()?
181
+
182
+ > `protected` `optional` **resumeFn**: () => `void`
183
+
184
+ Defined in: [src/async-semaphore.ts:94](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L94)
185
+
186
+ #### Returns
187
+
188
+ `void`
189
+
190
+ #### Inherited from
191
+
192
+ [`BinarySemaphore`](BinarySemaphore.md).[`resumeFn`](BinarySemaphore.md#resumefn)
193
+
194
+ ***
195
+
196
+ ### useDefaultTokens
197
+
198
+ > `protected` **useDefaultTokens**: `boolean`
199
+
200
+ Defined in: [src/async-semaphore.ts:92](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L92)
201
+
202
+ #### Inherited from
203
+
204
+ [`BinarySemaphore`](BinarySemaphore.md).[`useDefaultTokens`](BinarySemaphore.md#usedefaulttokens)
205
+
206
+ ***
207
+
208
+ ### waiting
209
+
210
+ > `readonly` **waiting**: [`Deque`](Deque.md)\<`undefined` \| [`SemaphoreTaskItem`](../interfaces/SemaphoreTaskItem.md)\>
211
+
212
+ Defined in: [src/async-semaphore.ts:89](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L89)
213
+
214
+ #### Inherited from
215
+
216
+ [`BinarySemaphore`](BinarySemaphore.md).[`waiting`](BinarySemaphore.md#waiting)
217
+
218
+ ## Accessors
219
+
220
+ ### activeCount
221
+
222
+ #### Get Signature
223
+
224
+ > **get** **activeCount**(): `number`
225
+
226
+ Defined in: [src/async-semaphore.ts:318](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L318)
227
+
228
+ Get the total count of all active operations.
229
+
230
+ This method returns the number of operations that are either:
231
+ - Waiting in the queue to acquire the semaphore (`pendingCount`).
232
+ - Already acquired the semaphore but have not yet released it.
233
+
234
+ ##### Returns
235
+
236
+ `number`
237
+
238
+ The total count of active operations, including both waiting and ongoing tasks.
239
+
240
+ #### Inherited from
241
+
242
+ [`BinarySemaphore`](BinarySemaphore.md).[`activeCount`](BinarySemaphore.md#activecount)
243
+
244
+ ***
245
+
246
+ ### pendingCount
247
+
248
+ #### Get Signature
249
+
250
+ > **get** **pendingCount**(): `number`
251
+
252
+ Defined in: [src/async-semaphore.ts:327](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L327)
253
+
254
+ Get the number of callers waiting on the semaphore, i.e. the number of pending promises.
255
+
256
+ ##### Returns
257
+
258
+ `number`
259
+
260
+ The number of waiters in the waiting list.
261
+
262
+ #### Inherited from
263
+
264
+ [`BinarySemaphore`](BinarySemaphore.md).[`pendingCount`](BinarySemaphore.md#pendingcount)
265
+
266
+ ## Methods
267
+
268
+ ### \_dispatchTask()
269
+
270
+ > **\_dispatchTask**(`task`, `options`?): `void`
271
+
272
+ Defined in: [src/async-semaphore.ts:212](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L212)
273
+
274
+ #### Parameters
275
+
276
+ ##### task
277
+
278
+ [`SemaphoreTaskItem`](../interfaces/SemaphoreTaskItem.md)
279
+
280
+ ##### options?
281
+
282
+ [`BinarySemaphoreReleaseOptions`](../interfaces/BinarySemaphoreReleaseOptions.md)
283
+
284
+ #### Returns
285
+
286
+ `void`
287
+
288
+ #### Inherited from
289
+
290
+ [`BinarySemaphore`](BinarySemaphore.md).[`_dispatchTask`](BinarySemaphore.md#_dispatchtask)
291
+
292
+ ***
293
+
294
+ ### \_newReleaser()
295
+
296
+ > **\_newReleaser**(`options`?): [`BinarySemaphoreReleaserFunc`](../interfaces/BinarySemaphoreReleaserFunc.md)
297
+
298
+ Defined in: [src/async-semaphore.ts:199](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L199)
299
+
300
+ #### Parameters
301
+
302
+ ##### options?
303
+
304
+ [`BinarySemaphoreReleaseOptions`](../interfaces/BinarySemaphoreReleaseOptions.md)
305
+
306
+ #### Returns
307
+
308
+ [`BinarySemaphoreReleaserFunc`](../interfaces/BinarySemaphoreReleaserFunc.md)
309
+
310
+ #### Inherited from
311
+
312
+ [`BinarySemaphore`](BinarySemaphore.md).[`_newReleaser`](BinarySemaphore.md#_newreleaser)
313
+
314
+ ***
315
+
316
+ ### abort()
317
+
318
+ > **abort**(`reason`?): `void`
319
+
320
+ Defined in: [src/async-semaphore.ts:301](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L301)
321
+
322
+ #### Parameters
323
+
324
+ ##### reason?
325
+
326
+ `any`
327
+
328
+ #### Returns
329
+
330
+ `void`
331
+
332
+ #### Inherited from
333
+
334
+ [`BinarySemaphore`](BinarySemaphore.md).[`abort`](BinarySemaphore.md#abort)
335
+
336
+ ***
337
+
338
+ ### acquire()
339
+
340
+ > **acquire**(`options`?): `Promise`\<[`BinarySemaphoreReleaserFunc`](../interfaces/BinarySemaphoreReleaserFunc.md)\>
341
+
342
+ Defined in: [src/async-semaphore.ts:243](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L243)
343
+
344
+ Acquire a token from the semaphore, thus decrement the number of available execution slots. If initFn is not used then the return value of the function can be discarded.
345
+
346
+ #### Parameters
347
+
348
+ ##### options?
349
+
350
+ [`BinarySemaphoreAcquireOptions`](../interfaces/BinarySemaphoreAcquireOptions.md)
351
+
352
+ #### Returns
353
+
354
+ `Promise`\<[`BinarySemaphoreReleaserFunc`](../interfaces/BinarySemaphoreReleaserFunc.md)\>
355
+
356
+ A promise that resolves to a release function when a token is acquired. If the semaphore is full, the caller will be added to a waiting queue.
357
+
358
+ #### Inherited from
359
+
360
+ [`BinarySemaphore`](BinarySemaphore.md).[`acquire`](BinarySemaphore.md#acquire)
361
+
362
+ ***
363
+
364
+ ### drain()
365
+
366
+ > **drain**(): `Promise`\<`any`[]\>
367
+
368
+ Defined in: [src/async-semaphore.ts:439](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L439)
369
+
370
+ Drains the semaphore and returns all the initialized tokens in an array. Draining is an ideal way to ensure there are no pending async tasks, for example before a process will terminate.
371
+
372
+ #### Returns
373
+
374
+ `Promise`\<`any`[]\>
375
+
376
+ #### Overrides
377
+
378
+ [`BinarySemaphore`](BinarySemaphore.md).[`drain`](BinarySemaphore.md#drain)
379
+
380
+ ***
381
+
382
+ ### init()
383
+
384
+ > **init**(`options`): `void`
385
+
386
+ Defined in: [src/async-semaphore.ts:193](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L193)
387
+
388
+ #### Parameters
389
+
390
+ ##### options
391
+
392
+ [`BinarySemaphoreOptions`](../interfaces/BinarySemaphoreOptions.md)
393
+
394
+ #### Returns
395
+
396
+ `void`
397
+
398
+ #### Inherited from
399
+
400
+ [`BinarySemaphore`](BinarySemaphore.md).[`init`](BinarySemaphore.md#init)
401
+
402
+ ***
403
+
404
+ ### initFree()
405
+
406
+ > **initFree**(`options`): `void`
407
+
408
+ Defined in: [src/async-semaphore.ts:408](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L408)
409
+
410
+ #### Parameters
411
+
412
+ ##### options
413
+
414
+ [`SemaphoreOptions`](../interfaces/SemaphoreOptions.md)
415
+
416
+ #### Returns
417
+
418
+ `void`
419
+
420
+ #### Overrides
421
+
422
+ [`BinarySemaphore`](BinarySemaphore.md).[`initFree`](BinarySemaphore.md#initfree)
423
+
424
+ ***
425
+
426
+ ### lock()
427
+
428
+ > **lock**(`options`?): `any`
429
+
430
+ Defined in: [src/async-semaphore.ts:435](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L435)
431
+
432
+ #### Parameters
433
+
434
+ ##### options?
435
+
436
+ [`BinarySemaphoreAcquireOptions`](../interfaces/BinarySemaphoreAcquireOptions.md)
437
+
438
+ #### Returns
439
+
440
+ `any`
441
+
442
+ #### Overrides
443
+
444
+ [`BinarySemaphore`](BinarySemaphore.md).[`lock`](BinarySemaphore.md#lock)
445
+
446
+ ***
447
+
448
+ ### onReleased()
449
+
450
+ > **onReleased**(`options`?): `void`
451
+
452
+ Defined in: [src/async-semaphore.ts:177](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L177)
453
+
454
+ #### Parameters
455
+
456
+ ##### options?
457
+
458
+ [`BinarySemaphoreReleaseOptions`](../interfaces/BinarySemaphoreReleaseOptions.md)
459
+
460
+ #### Returns
461
+
462
+ `void`
463
+
464
+ #### Inherited from
465
+
466
+ [`BinarySemaphore`](BinarySemaphore.md).[`onReleased`](BinarySemaphore.md#onreleased)
467
+
468
+ ***
469
+
470
+ ### release()
471
+
472
+ > **release**(`options`?): `void`
473
+
474
+ Defined in: [src/async-semaphore.ts:288](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L288)
475
+
476
+ Releases the semaphore, incrementing the number of free execution slots. If there are tasks in the waiting queue, the next task will be dispatched.
477
+
478
+ #### Parameters
479
+
480
+ ##### options?
481
+
482
+ [`BinarySemaphoreReleaseOptions`](../interfaces/BinarySemaphoreReleaseOptions.md)
483
+
484
+ #### Returns
485
+
486
+ `void`
487
+
488
+ #### Inherited from
489
+
490
+ [`BinarySemaphore`](BinarySemaphore.md).[`release`](BinarySemaphore.md#release)
491
+
492
+ ***
493
+
494
+ ### tryAcquire()
495
+
496
+ > **tryAcquire**(`options`?): `any`
497
+
498
+ Defined in: [src/async-semaphore.ts:416](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L416)
499
+
500
+ Attempt to acquire a token from the semaphore, if one is available immediately. Otherwise, return undefined.
501
+
502
+ #### Parameters
503
+
504
+ ##### options?
505
+
506
+ [`BinarySemaphoreAcquireOptions`](../interfaces/BinarySemaphoreAcquireOptions.md)
507
+
508
+ #### Returns
509
+
510
+ `any`
511
+
512
+ Returns a token if the semaphore is not full; otherwise, returns `undefined`.
513
+
514
+ #### Overrides
515
+
516
+ [`BinarySemaphore`](BinarySemaphore.md).[`tryAcquire`](BinarySemaphore.md#tryacquire)
517
+
518
+ ***
519
+
520
+ ### unlock()
521
+
522
+ > **unlock**(`token`?): `void`
523
+
524
+ Defined in: [src/async-semaphore.ts:431](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-semaphore.ts#L431)
525
+
526
+ #### Parameters
527
+
528
+ ##### token?
529
+
530
+ `any`
531
+
532
+ #### Returns
533
+
534
+ `void`
535
+
536
+ #### Overrides
537
+
538
+ [`BinarySemaphore`](BinarySemaphore.md).[`unlock`](BinarySemaphore.md#unlock)
@@ -0,0 +1,184 @@
1
+ [**@isdk/util**](../README.md)
2
+
3
+ ***
4
+
5
+ [@isdk/util](../globals.md) / SignalGate
6
+
7
+ # Class: SignalGate\<T\>
8
+
9
+ Defined in: [src/async-signal-gate.ts:20](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-signal-gate.ts#L20)
10
+
11
+ An asynchronous signal gate that blocks operations until a signal is emitted.
12
+ This class allows multiple awaiters to wait for a signal and resolves all pending promises with the emitted value.
13
+ The gate can be reset to reuse for subsequent signals.
14
+
15
+ ## Example
16
+
17
+ ```typescript
18
+ // Default type is void, can call signal() without parameters
19
+ const gate = new SignalGate();
20
+ gate.signal(); // No parameters required
21
+
22
+ // Example with explicit type
23
+ const valueGate = new SignalGate<number>();
24
+ valueGate.signal(42); // Must provide a number value
25
+ ```
26
+
27
+ ## Type Parameters
28
+
29
+ ### T
30
+
31
+ `T` = `void`
32
+
33
+ ## Constructors
34
+
35
+ ### Constructor
36
+
37
+ > **new SignalGate**\<`T`\>(): `SignalGate`\<`T`\>
38
+
39
+ #### Returns
40
+
41
+ `SignalGate`\<`T`\>
42
+
43
+ ## Properties
44
+
45
+ ### \_isSignaled
46
+
47
+ > `protected` **\_isSignaled**: `boolean` = `false`
48
+
49
+ Defined in: [src/async-signal-gate.ts:21](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-signal-gate.ts#L21)
50
+
51
+ ***
52
+
53
+ ### \_signalValue
54
+
55
+ > `protected` **\_signalValue**: `undefined` \| `T`
56
+
57
+ Defined in: [src/async-signal-gate.ts:22](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-signal-gate.ts#L22)
58
+
59
+ ***
60
+
61
+ ### waitQueue
62
+
63
+ > `protected` **waitQueue**: `object`[] = `[]`
64
+
65
+ Defined in: [src/async-signal-gate.ts:23](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-signal-gate.ts#L23)
66
+
67
+ #### reject()
68
+
69
+ > **reject**: (`error`) => `void`
70
+
71
+ ##### Parameters
72
+
73
+ ###### error
74
+
75
+ `any`
76
+
77
+ ##### Returns
78
+
79
+ `void`
80
+
81
+ #### resolve()
82
+
83
+ > **resolve**: (`value`) => `void`
84
+
85
+ ##### Parameters
86
+
87
+ ###### value
88
+
89
+ `T`
90
+
91
+ ##### Returns
92
+
93
+ `void`
94
+
95
+ ## Accessors
96
+
97
+ ### signaled
98
+
99
+ #### Get Signature
100
+
101
+ > **get** **signaled**(): `boolean`
102
+
103
+ Defined in: [src/async-signal-gate.ts:28](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-signal-gate.ts#L28)
104
+
105
+ ##### Returns
106
+
107
+ `boolean`
108
+
109
+ ## Methods
110
+
111
+ ### abort()
112
+
113
+ > **abort**(`reason`?): `void`
114
+
115
+ Defined in: [src/async-signal-gate.ts:65](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-signal-gate.ts#L65)
116
+
117
+ Aborts all pending waits, rejecting their promises with an error.
118
+ This does **not** reset the signal state (the gate remains signaled or unsignaled).
119
+
120
+ #### Parameters
121
+
122
+ ##### reason?
123
+
124
+ `any`
125
+
126
+ The reason for aborting the waits.
127
+
128
+ #### Returns
129
+
130
+ `void`
131
+
132
+ ***
133
+
134
+ ### reset()
135
+
136
+ > **reset**(): `void`
137
+
138
+ Defined in: [src/async-signal-gate.ts:53](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-signal-gate.ts#L53)
139
+
140
+ Resets the gate to its initial state, allowing a new signal to be emitted.
141
+
142
+ #### Returns
143
+
144
+ `void`
145
+
146
+ ***
147
+
148
+ ### signal()
149
+
150
+ > **signal**(`value`?): `void`
151
+
152
+ Defined in: [src/async-signal-gate.ts:38](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-signal-gate.ts#L38)
153
+
154
+ Emits the signal with an optional value, resolving all pending [wait](#wait) promises.
155
+ Subsequent calls have no effect until [reset](#reset) is called.
156
+
157
+ #### Parameters
158
+
159
+ ##### value?
160
+
161
+ `T`
162
+
163
+ The value to emit with the signal (only required if T is not void).
164
+
165
+ #### Returns
166
+
167
+ `void`
168
+
169
+ ***
170
+
171
+ ### wait()
172
+
173
+ > **wait**(): `Promise`\<`T`\>
174
+
175
+ Defined in: [src/async-signal-gate.ts:83](https://github.com/isdk/util.js/blob/f6ac1e1b241d01211870dd55d000c1e9d4daa404/src/async-signal-gate.ts#L83)
176
+
177
+ Returns a promise that resolves with the emitted signal value.
178
+ If called after the signal has been emitted, resolves immediately with the stored value.
179
+
180
+ #### Returns
181
+
182
+ `Promise`\<`T`\>
183
+
184
+ A promise resolving to the signal value (type T).