performance-helpers 1.0.0 → 1.0.1
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/README.md +12 -2
- package/package.json +146 -1
- package/src/index.js +1 -0
- package/.eslintrc.cjs +0 -22
- package/.nojekyll +0 -0
- package/.prettierrc +0 -6
- package/CONTRIBUTING.md +0 -178
- package/assets/1_Caching.md +0 -4
- package/assets/2_Parallelizing.md +0 -18
- package/assets/3_Logging.md +0 -3
- package/assets/404.md +0 -3
- package/assets/4_Utils.md +0 -10
- package/assets/logo.png +0 -0
- package/assets/navigation.md +0 -10
- package/bench/README.md +0 -97
- package/bench/results.json +0 -94
- package/bench/results.md +0 -233
- package/bench/run.js +0 -2639
- package/bench/worker.js +0 -43
- package/docs/README.md +0 -38
- package/docs/docs-typedoc.json +0 -38714
- package/docs/helpers/constants/README.md +0 -34
- package/docs/helpers/constants/variables/DEFAULT_AUTOSCALE_BACKOFF_MAX_MULTIPLIER.md +0 -9
- package/docs/helpers/constants/variables/DEFAULT_AUTOSCALE_COOLDOWN_MS.md +0 -9
- package/docs/helpers/constants/variables/DEFAULT_AUTOSCALE_INTERVAL_MS.md +0 -9
- package/docs/helpers/constants/variables/DEFAULT_AUTOSCALE_MIN_INTERVAL_MS.md +0 -9
- package/docs/helpers/constants/variables/DEFAULT_BACKPRESSURE_QUEUE_CAPACITY.md +0 -9
- package/docs/helpers/constants/variables/DEFAULT_BACKPRESSURE_REFILL_INTERVAL_MS.md +0 -9
- package/docs/helpers/constants/variables/DEFAULT_BATCH_MAX_SIZE.md +0 -9
- package/docs/helpers/constants/variables/DEFAULT_CACHE_DEFAULT_TTL_MS.md +0 -9
- package/docs/helpers/constants/variables/DEFAULT_CACHE_MAX_POOL_SIZE.md +0 -9
- package/docs/helpers/constants/variables/DEFAULT_CACHE_MAX_WEIGHT_BYTES.md +0 -9
- package/docs/helpers/constants/variables/DEFAULT_HISTOGRAM_BUCKET_COUNT.md +0 -9
- package/docs/helpers/constants/variables/DEFAULT_HISTOGRAM_MAX_VALUE.md +0 -9
- package/docs/helpers/constants/variables/DEFAULT_MAX_CLEANUP_PER_TICK.md +0 -9
- package/docs/helpers/constants/variables/DEFAULT_QUEUE_CAPACITY.md +0 -9
- package/docs/helpers/constants/variables/DEFAULT_REAPER_MIN_INTERVAL_MS.md +0 -9
- package/docs/helpers/constants/variables/DEFAULT_REFILL_INTERVAL_MS.md +0 -9
- package/docs/helpers/constants/variables/DEFAULT_RETRY_BASE_DELAY_MS.md +0 -9
- package/docs/helpers/constants/variables/DEFAULT_RETRY_MAX_DELAY_MS.md +0 -9
- package/docs/helpers/constants/variables/DEFAULT_TIMEOUT_MS.md +0 -9
- package/docs/helpers/constants/variables/ENCODE_CACHE_LARGE_KEY_LENGTH.md +0 -9
- package/docs/helpers/constants/variables/MAX_DEEP_EQUAL_DEPTH.md +0 -9
- package/docs/helpers/constants/variables/MS_PER_MIN.md +0 -9
- package/docs/helpers/constants/variables/MS_PER_SEC.md +0 -9
- package/docs/helpers/constants/variables/default.md +0 -103
- package/docs/helpers/jsdoc-types/README.md +0 -33
- package/docs/helpers/jsdoc-types/interfaces/BufferDecoder.md +0 -23
- package/docs/helpers/jsdoc-types/interfaces/BufferEncoder.md +0 -23
- package/docs/helpers/jsdoc-types/interfaces/CacheNode.md +0 -43
- package/docs/helpers/jsdoc-types/interfaces/CommonPoolOptions.md +0 -31
- package/docs/helpers/jsdoc-types/interfaces/PendingResponseEntry.md +0 -51
- package/docs/helpers/jsdoc-types/interfaces/PostMessageOptions.md +0 -39
- package/docs/helpers/jsdoc-types/interfaces/PowerBatchOptions.md +0 -13
- package/docs/helpers/jsdoc-types/interfaces/PowerCacheOptions.md +0 -115
- package/docs/helpers/jsdoc-types/interfaces/PowerChunkingOptions.md +0 -31
- package/docs/helpers/jsdoc-types/interfaces/PowerCircuitOptions.md +0 -45
- package/docs/helpers/jsdoc-types/interfaces/PowerDeadlineOptions.md +0 -101
- package/docs/helpers/jsdoc-types/interfaces/PowerDeferOptions.md +0 -13
- package/docs/helpers/jsdoc-types/interfaces/PowerEventBusOptions.md +0 -19
- package/docs/helpers/jsdoc-types/interfaces/PowerLatchOptions.md +0 -23
- package/docs/helpers/jsdoc-types/interfaces/PowerLoggerOptions.md +0 -51
- package/docs/helpers/jsdoc-types/interfaces/PowerObserverOptions.md +0 -25
- package/docs/helpers/jsdoc-types/interfaces/PowerPoolOptions.md +0 -85
- package/docs/helpers/jsdoc-types/interfaces/PowerQueueOptions.md +0 -13
- package/docs/helpers/jsdoc-types/interfaces/PowerRetryOptions.md +0 -83
- package/docs/helpers/jsdoc-types/interfaces/PowerSlidingWindowOptions.md +0 -19
- package/docs/helpers/jsdoc-types/interfaces/PowerTTLMapOptions.md +0 -27
- package/docs/helpers/jsdoc-types/interfaces/PowerThrottleOptions.md +0 -31
- package/docs/helpers/jsdoc-types/interfaces/WorkerObj.md +0 -55
- package/docs/helpers/powerBackpressure/README.md +0 -17
- package/docs/helpers/powerBackpressure/classes/PowerBackpressure.md +0 -368
- package/docs/helpers/powerBatch/README.md +0 -17
- package/docs/helpers/powerBatch/classes/PowerBatch.md +0 -139
- package/docs/helpers/powerBuffer/README.md +0 -26
- package/docs/helpers/powerBuffer/functions/b2o.md +0 -25
- package/docs/helpers/powerBuffer/functions/o2b.md +0 -23
- package/docs/helpers/powerBuffer/functions/o2u8.md +0 -33
- package/docs/helpers/powerBuffer/functions/u82o.md +0 -30
- package/docs/helpers/powerBulkhead/README.md +0 -17
- package/docs/helpers/powerBulkhead/classes/PowerBulkhead.md +0 -302
- package/docs/helpers/powerCache/README.md +0 -29
- package/docs/helpers/powerCache/classes/PowerCache.md +0 -933
- package/docs/helpers/powerCache/classes/PowerMemoizer.md +0 -244
- package/docs/helpers/powerCache/classes/PowerTimedCache.md +0 -302
- package/docs/helpers/powerCache/functions/simpleArgsKey.md +0 -31
- package/docs/helpers/powerChunking/README.md +0 -17
- package/docs/helpers/powerChunking/classes/PowerChunker.md +0 -78
- package/docs/helpers/powerCircuit/README.md +0 -23
- package/docs/helpers/powerCircuit/classes/PowerCircuit.md +0 -167
- package/docs/helpers/powerDeadline/README.md +0 -23
- package/docs/helpers/powerDeadline/classes/PowerDeadline.md +0 -88
- package/docs/helpers/powerDefer/README.md +0 -17
- package/docs/helpers/powerDefer/classes/PowerDefer.md +0 -134
- package/docs/helpers/powerEventBus/README.md +0 -23
- package/docs/helpers/powerEventBus/classes/PowerEventBus.md +0 -330
- package/docs/helpers/powerHistogram/README.md +0 -17
- package/docs/helpers/powerHistogram/classes/PowerHistogram.md +0 -285
- package/docs/helpers/powerLatch/README.md +0 -17
- package/docs/helpers/powerLatch/classes/PowerLatch.md +0 -264
- package/docs/helpers/powerLogger/README.md +0 -17
- package/docs/helpers/powerLogger/classes/PowerLogger.md +0 -290
- package/docs/helpers/powerObserver/README.md +0 -23
- package/docs/helpers/powerObserver/classes/PowerObserver.md +0 -213
- package/docs/helpers/powerPermitGate/README.md +0 -11
- package/docs/helpers/powerPermitGate/classes/PowerPermitGate.md +0 -248
- package/docs/helpers/powerPool/README.md +0 -36
- package/docs/helpers/powerPool/classes/PowerPool.md +0 -973
- package/docs/helpers/powerPool/classes/PowerPoolShutdownError.md +0 -67
- package/docs/helpers/powerQueue/README.md +0 -11
- package/docs/helpers/powerQueue/classes/PowerQueue.md +0 -302
- package/docs/helpers/powerRateLimit/README.md +0 -17
- package/docs/helpers/powerRateLimit/classes/PowerRateLimit.md +0 -187
- package/docs/helpers/powerRetry/README.md +0 -23
- package/docs/helpers/powerRetry/classes/PowerRetry.md +0 -106
- package/docs/helpers/powerScheduler/README.md +0 -11
- package/docs/helpers/powerScheduler/classes/PowerScheduler.md +0 -135
- package/docs/helpers/powerSemaphore/README.md +0 -17
- package/docs/helpers/powerSemaphore/classes/PowerSemaphore.md +0 -173
- package/docs/helpers/powerSlidingWindow/README.md +0 -11
- package/docs/helpers/powerSlidingWindow/classes/PowerSlidingWindow.md +0 -83
- package/docs/helpers/powerSubscriberSet/README.md +0 -15
- package/docs/helpers/powerSubscriberSet/classes/PowerSubscriberSet.md +0 -251
- package/docs/helpers/powerSubscriberSet/functions/cleanupWeakRefs.md +0 -21
- package/docs/helpers/powerTTLMap/README.md +0 -17
- package/docs/helpers/powerTTLMap/classes/PowerTTLMap.md +0 -326
- package/docs/helpers/powerThrottle/README.md +0 -17
- package/docs/helpers/powerThrottle/classes/PowerThrottle.md +0 -216
- package/docs/index/README.md +0 -205
- package/docs/utils/errors/README.md +0 -12
- package/docs/utils/errors/functions/formatErrorObj.md +0 -30
- package/docs/utils/errors/functions/normalizeError.md +0 -50
- package/docs/utils/now/README.md +0 -19
- package/docs/utils/now/functions/measureAsync.md +0 -37
- package/docs/utils/now/functions/measureSync.md +0 -54
- package/docs/utils/now/functions/nowMs.md +0 -24
- package/guides/autoscale.md +0 -80
- package/guides/errors.md +0 -41
- package/guides/metaGuide.md +0 -440
- package/guides/now.md +0 -56
- package/guides/powerBackpressure.md +0 -110
- package/guides/powerBatch.md +0 -82
- package/guides/powerBuffer.md +0 -86
- package/guides/powerBulkhead.md +0 -61
- package/guides/powerCache.md +0 -269
- package/guides/powerChunking.md +0 -130
- package/guides/powerCircuit.md +0 -84
- package/guides/powerDeadline.md +0 -99
- package/guides/powerDefer.md +0 -56
- package/guides/powerEventBus.md +0 -89
- package/guides/powerHistogram.md +0 -71
- package/guides/powerLatch.md +0 -94
- package/guides/powerLogger.md +0 -129
- package/guides/powerObserver.md +0 -65
- package/guides/powerPermitGate.md +0 -52
- package/guides/powerPool.md +0 -321
- package/guides/powerQueue.md +0 -112
- package/guides/powerRateLimit.md +0 -37
- package/guides/powerRetry.md +0 -54
- package/guides/powerScheduler.md +0 -41
- package/guides/powerSemaphore.md +0 -65
- package/guides/powerSlidingWindow.md +0 -63
- package/guides/powerSubscriberSet.md +0 -48
- package/guides/powerTTLMap.md +0 -58
- package/guides/powerThrottle.md +0 -152
- package/index.html +0 -57
- package/results.json +0 -6692
- package/scripts/find-missing-jsdoc.js +0 -62
- package/scripts/modernize-optional-chaining.cjs +0 -36
- package/scripts/pool-debug.mjs +0 -29
- package/scripts/repro_powercache.js +0 -14
- package/scripts/static-audit-exports.cjs +0 -93
- package/scripts/static-audit-exports.json +0 -518
- package/test/powerBackpressure.test.js +0 -114
- package/test/powerBatch.branches.extra.test.js +0 -122
- package/test/powerBatch.test.js +0 -79
- package/test/powerBuffer.test.js +0 -125
- package/test/powerBulkhead.test.js +0 -210
- package/test/powerCache.branches.test.js +0 -233
- package/test/powerCache.bulk.test.js +0 -31
- package/test/powerCache.getorset.test.js +0 -110
- package/test/powerCache.hitRate.test.js +0 -35
- package/test/powerCache.inflight.test.js +0 -24
- package/test/powerCache.iterator.test.js +0 -18
- package/test/powerCache.misses.test.js +0 -52
- package/test/powerCache.more.test.js +0 -118
- package/test/powerCache.test.js +0 -37
- package/test/powerCache.timeout.test.js +0 -25
- package/test/powerCache.touch.test.js +0 -46
- package/test/powerChunking.branches.extra.test.js +0 -155
- package/test/powerChunking.errors.test.js +0 -177
- package/test/powerChunking.test.js +0 -39
- package/test/powerCircuit.observability.test.js +0 -71
- package/test/powerCircuit.test.js +0 -74
- package/test/powerDeadline.test.js +0 -140
- package/test/powerDefer.test.js +0 -55
- package/test/powerErrors.test.js +0 -32
- package/test/powerEventBus.branches.extra.test.js +0 -70
- package/test/powerEventBus.extra.test.js +0 -72
- package/test/powerEventBus.max.test.js +0 -43
- package/test/powerEventBus.more.test.js +0 -121
- package/test/powerEventBus.once_off.test.js +0 -17
- package/test/powerEventBus.test.js +0 -74
- package/test/powerEventBus.uncovered.test.js +0 -57
- package/test/powerEventBus.weak.test.js +0 -18
- package/test/powerHistogram.test.js +0 -73
- package/test/powerLatch.branches.extra.test.js +0 -115
- package/test/powerLatch.test.js +0 -57
- package/test/powerLogger.branches.test.js +0 -98
- package/test/powerLogger.formatter.name.test.js +0 -58
- package/test/powerLogger.json.test.js +0 -88
- package/test/powerLogger.output.test.js +0 -81
- package/test/powerLogger.table.debug.test.js +0 -77
- package/test/powerLogger.test.js +0 -59
- package/test/powerMemoizer.memoize.test.js +0 -100
- package/test/powerMemoizer.test.js +0 -85
- package/test/powerObserver.test.js +0 -129
- package/test/powerPermitGate.test.js +0 -66
- package/test/powerPool.autoTransfer.test.js +0 -100
- package/test/powerPool.autoscale.extra.test.js +0 -88
- package/test/powerPool.autoscale.test.js +0 -136
- package/test/powerPool.awaitDefaultTimeout.test.js +0 -52
- package/test/powerPool.awaitTimeout.test.js +0 -22
- package/test/powerPool.batch.test.js +0 -170
- package/test/powerPool.branches.extra2.test.js +0 -42
- package/test/powerPool.branches.test.js +0 -102
- package/test/powerPool.browser.messageerror.test.js +0 -45
- package/test/powerPool.correlation.test.js +0 -26
- package/test/powerPool.correlationId.test.js +0 -63
- package/test/powerPool.dispose.test.js +0 -49
- package/test/powerPool.drain.test.js +0 -57
- package/test/powerPool.events.test.js +0 -131
- package/test/powerPool.more.extra.test.js +0 -99
- package/test/powerPool.more.test.js +0 -283
- package/test/powerPool.node.messageerror.test.js +0 -46
- package/test/powerPool.postMessage.promise.test.js +0 -83
- package/test/powerPool.queueHigh.test.js +0 -55
- package/test/powerPool.queueSaturation.test.js +0 -51
- package/test/powerPool.rapidResize.test.js +0 -55
- package/test/powerPool.resize.overload.test.js +0 -65
- package/test/powerPool.resize.test.js +0 -70
- package/test/powerPool.shutdown.test.js +0 -38
- package/test/powerPool.stats.test.js +0 -40
- package/test/powerPool.stopThePress.test.js +0 -94
- package/test/powerPool.terminateShutdown.test.js +0 -22
- package/test/powerPool.test.js +0 -525
- package/test/powerPool.timers.test.js +0 -55
- package/test/powerPool.uncovered.test.js +0 -407
- package/test/powerPool.workerId.test.js +0 -47
- package/test/powerQueue.iterators.test.js +0 -67
- package/test/powerQueue.saturation.test.js +0 -18
- package/test/powerQueue.test.js +0 -48
- package/test/powerQueue.unshiftMany.test.js +0 -49
- package/test/powerRateLimit.atomic.test.js +0 -80
- package/test/powerRateLimit.extra.test.js +0 -145
- package/test/powerRateLimit.functions.test.js +0 -106
- package/test/powerRateLimit.test.js +0 -38
- package/test/powerRetry.attemptTimeout.test.js +0 -51
- package/test/powerRetry.test.js +0 -121
- package/test/powerScheduler.test.js +0 -126
- package/test/powerSemaphore.test.js +0 -108
- package/test/powerSlidingWindow.pool.test.js +0 -55
- package/test/powerSlidingWindow.test.js +0 -25
- package/test/powerSubscriberSet.test.js +0 -125
- package/test/powerTTLMap.test.js +0 -125
- package/test/powerThrottle.pool.test.js +0 -54
- package/test/powerThrottle.refill.test.js +0 -22
- package/test/powerThrottle.reserve.test.js +0 -46
- package/test/powerThrottle.test.js +0 -45
- package/test/powerTimedCache.test.js +0 -73
- package/test/umd.bundle.branches.test.js +0 -100
- package/test/umd.bundle.cache-timers.test.js +0 -48
- package/test/umd.bundle.exhaustive.test.js +0 -158
- package/test/umd.bundle.fuzz.test.js +0 -86
- package/test/umd.bundle.hasEqual.more.test.js +0 -68
- package/test/umd.bundle.hasEqual.test.js +0 -104
- package/test/umd.bundle.logger-extra.test.js +0 -48
- package/test/umd.bundle.more-coverage-2.test.js +0 -67
- package/test/umd.bundle.pool.test.js +0 -134
- package/test/umd.bundle.test.js +0 -265
- package/test/utils.measure.test.js +0 -49
- package/test/utils.now.extra.test.js +0 -30
- package/test/utils.now.more.test.js +0 -57
- package/tsconfig.json +0 -16
- package/typedoc.json +0 -25
- package/vite.config.js +0 -31
- package/vitest.config.js +0 -17
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
[**performance-helpers**](../../../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[performance-helpers](../../../README.md) / [helpers/powerPool](../README.md) / PowerPoolShutdownError
|
|
6
|
-
|
|
7
|
-
# Class: PowerPoolShutdownError
|
|
8
|
-
|
|
9
|
-
PowerPoolShutdownError
|
|
10
|
-
|
|
11
|
-
Error thrown when the `PowerPool` is shut down and pending tasks are rejected.
|
|
12
|
-
|
|
13
|
-
PowerPoolShutdownError
|
|
14
|
-
|
|
15
|
-
## Extends
|
|
16
|
-
|
|
17
|
-
- `Error`
|
|
18
|
-
|
|
19
|
-
## Constructors
|
|
20
|
-
|
|
21
|
-
### Constructor
|
|
22
|
-
|
|
23
|
-
> **new PowerPoolShutdownError**(`message?`): `PowerPoolShutdownError`
|
|
24
|
-
|
|
25
|
-
#### Parameters
|
|
26
|
-
|
|
27
|
-
##### message?
|
|
28
|
-
|
|
29
|
-
`string` = `'PowerPool has been shut down'`
|
|
30
|
-
|
|
31
|
-
#### Returns
|
|
32
|
-
|
|
33
|
-
`PowerPoolShutdownError`
|
|
34
|
-
|
|
35
|
-
#### Overrides
|
|
36
|
-
|
|
37
|
-
`Error.constructor`
|
|
38
|
-
|
|
39
|
-
## Properties
|
|
40
|
-
|
|
41
|
-
### message
|
|
42
|
-
|
|
43
|
-
> **message**: `string`
|
|
44
|
-
|
|
45
|
-
#### Inherited from
|
|
46
|
-
|
|
47
|
-
`Error.message`
|
|
48
|
-
|
|
49
|
-
***
|
|
50
|
-
|
|
51
|
-
### name
|
|
52
|
-
|
|
53
|
-
> **name**: `string`
|
|
54
|
-
|
|
55
|
-
#### Inherited from
|
|
56
|
-
|
|
57
|
-
`Error.name`
|
|
58
|
-
|
|
59
|
-
***
|
|
60
|
-
|
|
61
|
-
### stack?
|
|
62
|
-
|
|
63
|
-
> `optional` **stack?**: `string`
|
|
64
|
-
|
|
65
|
-
#### Inherited from
|
|
66
|
-
|
|
67
|
-
`Error.stack`
|
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
[**performance-helpers**](../../../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[performance-helpers](../../../README.md) / [helpers/powerQueue](../README.md) / PowerQueue
|
|
6
|
-
|
|
7
|
-
# Class: PowerQueue
|
|
8
|
-
|
|
9
|
-
PowerQueue
|
|
10
|
-
|
|
11
|
-
Lightweight resizable ring-buffer queue with O(1) enqueue/dequeue.
|
|
12
|
-
Designed as a small, dependency-free helper for high-throughput queues.
|
|
13
|
-
|
|
14
|
-
PowerQueue
|
|
15
|
-
|
|
16
|
-
## Example
|
|
17
|
-
|
|
18
|
-
```ts
|
|
19
|
-
const q = new PowerQueue(8);
|
|
20
|
-
q.push(1);
|
|
21
|
-
q.push(2);
|
|
22
|
-
q.shift(); // 1
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## Constructors
|
|
26
|
-
|
|
27
|
-
### Constructor
|
|
28
|
-
|
|
29
|
-
> **new PowerQueue**(`initialCapacity?`): `PowerQueue`
|
|
30
|
-
|
|
31
|
-
Create a PowerQueue.
|
|
32
|
-
|
|
33
|
-
#### Parameters
|
|
34
|
-
|
|
35
|
-
##### initialCapacity?
|
|
36
|
-
|
|
37
|
-
`number` = `16`
|
|
38
|
-
|
|
39
|
-
Initial capacity (rounded up to power-of-two).
|
|
40
|
-
|
|
41
|
-
#### Returns
|
|
42
|
-
|
|
43
|
-
`PowerQueue`
|
|
44
|
-
|
|
45
|
-
## Properties
|
|
46
|
-
|
|
47
|
-
### \_buffer
|
|
48
|
-
|
|
49
|
-
> **\_buffer**: `any`[]
|
|
50
|
-
|
|
51
|
-
***
|
|
52
|
-
|
|
53
|
-
### \_capacity
|
|
54
|
-
|
|
55
|
-
> **\_capacity**: `number`
|
|
56
|
-
|
|
57
|
-
***
|
|
58
|
-
|
|
59
|
-
### \_head
|
|
60
|
-
|
|
61
|
-
> **\_head**: `number`
|
|
62
|
-
|
|
63
|
-
***
|
|
64
|
-
|
|
65
|
-
### \_mask
|
|
66
|
-
|
|
67
|
-
> **\_mask**: `number`
|
|
68
|
-
|
|
69
|
-
***
|
|
70
|
-
|
|
71
|
-
### \_size
|
|
72
|
-
|
|
73
|
-
> **\_size**: `number`
|
|
74
|
-
|
|
75
|
-
***
|
|
76
|
-
|
|
77
|
-
### \_tail
|
|
78
|
-
|
|
79
|
-
> **\_tail**: `number`
|
|
80
|
-
|
|
81
|
-
## Accessors
|
|
82
|
-
|
|
83
|
-
### capacity
|
|
84
|
-
|
|
85
|
-
#### Get Signature
|
|
86
|
-
|
|
87
|
-
> **get** **capacity**(): `number`
|
|
88
|
-
|
|
89
|
-
Internal buffer capacity (always a power-of-two).
|
|
90
|
-
|
|
91
|
-
##### Returns
|
|
92
|
-
|
|
93
|
-
`number`
|
|
94
|
-
|
|
95
|
-
***
|
|
96
|
-
|
|
97
|
-
### isEmpty
|
|
98
|
-
|
|
99
|
-
#### Get Signature
|
|
100
|
-
|
|
101
|
-
> **get** **isEmpty**(): `boolean`
|
|
102
|
-
|
|
103
|
-
Whether the queue is empty.
|
|
104
|
-
|
|
105
|
-
##### Returns
|
|
106
|
-
|
|
107
|
-
`boolean`
|
|
108
|
-
|
|
109
|
-
***
|
|
110
|
-
|
|
111
|
-
### length
|
|
112
|
-
|
|
113
|
-
#### Get Signature
|
|
114
|
-
|
|
115
|
-
> **get** **length**(): `number`
|
|
116
|
-
|
|
117
|
-
Number of items currently queued.
|
|
118
|
-
|
|
119
|
-
##### Returns
|
|
120
|
-
|
|
121
|
-
`number`
|
|
122
|
-
|
|
123
|
-
## Methods
|
|
124
|
-
|
|
125
|
-
### \[iterator\]()
|
|
126
|
-
|
|
127
|
-
> **\[iterator\]**(): `Iterator`\<`any`, `any`, `any`\>
|
|
128
|
-
|
|
129
|
-
Iterator (non-destructive) yielding items in FIFO order.
|
|
130
|
-
Allows `for...of` and spread (`[...queue]`) without consuming the queue.
|
|
131
|
-
|
|
132
|
-
#### Returns
|
|
133
|
-
|
|
134
|
-
`Iterator`\<`any`, `any`, `any`\>
|
|
135
|
-
|
|
136
|
-
***
|
|
137
|
-
|
|
138
|
-
### clear()
|
|
139
|
-
|
|
140
|
-
> **clear**(): `void`
|
|
141
|
-
|
|
142
|
-
Remove all items from the queue.
|
|
143
|
-
|
|
144
|
-
#### Returns
|
|
145
|
-
|
|
146
|
-
`void`
|
|
147
|
-
|
|
148
|
-
***
|
|
149
|
-
|
|
150
|
-
### drain()
|
|
151
|
-
|
|
152
|
-
> **drain**(): `Iterator`\<`any`, `any`, `any`\>
|
|
153
|
-
|
|
154
|
-
Consuming drain iterator: yields items in FIFO order and removes them
|
|
155
|
-
from the queue as they are iterated.
|
|
156
|
-
Useful for streaming/processing and emptying the queue without manual loops.
|
|
157
|
-
|
|
158
|
-
#### Returns
|
|
159
|
-
|
|
160
|
-
`Iterator`\<`any`, `any`, `any`\>
|
|
161
|
-
|
|
162
|
-
***
|
|
163
|
-
|
|
164
|
-
### entries()
|
|
165
|
-
|
|
166
|
-
> **entries**(): `Iterator`\<\[`number`, `any`\], `any`, `any`\>
|
|
167
|
-
|
|
168
|
-
Non-destructive entries iterator that yields [index, value] pairs where
|
|
169
|
-
index is the zero-based position in the queue (0 is the head).
|
|
170
|
-
|
|
171
|
-
#### Returns
|
|
172
|
-
|
|
173
|
-
`Iterator`\<\[`number`, `any`\], `any`, `any`\>
|
|
174
|
-
|
|
175
|
-
***
|
|
176
|
-
|
|
177
|
-
### keys()
|
|
178
|
-
|
|
179
|
-
> **keys**(): `Iterator`\<`number`, `any`, `any`\>
|
|
180
|
-
|
|
181
|
-
Return an iterator of keys (zero-based indexes from the head).
|
|
182
|
-
|
|
183
|
-
#### Returns
|
|
184
|
-
|
|
185
|
-
`Iterator`\<`number`, `any`, `any`\>
|
|
186
|
-
|
|
187
|
-
***
|
|
188
|
-
|
|
189
|
-
### peek()
|
|
190
|
-
|
|
191
|
-
> **peek**(): `any`
|
|
192
|
-
|
|
193
|
-
Peek at the head item without removing it.
|
|
194
|
-
|
|
195
|
-
#### Returns
|
|
196
|
-
|
|
197
|
-
`any`
|
|
198
|
-
|
|
199
|
-
The head item or `undefined` when empty.
|
|
200
|
-
|
|
201
|
-
***
|
|
202
|
-
|
|
203
|
-
### push()
|
|
204
|
-
|
|
205
|
-
> **push**(`item`): `number`
|
|
206
|
-
|
|
207
|
-
Enqueue an item at the tail.
|
|
208
|
-
|
|
209
|
-
#### Parameters
|
|
210
|
-
|
|
211
|
-
##### item
|
|
212
|
-
|
|
213
|
-
`any`
|
|
214
|
-
|
|
215
|
-
Item to enqueue.
|
|
216
|
-
|
|
217
|
-
#### Returns
|
|
218
|
-
|
|
219
|
-
`number`
|
|
220
|
-
|
|
221
|
-
New queue length after push.
|
|
222
|
-
|
|
223
|
-
***
|
|
224
|
-
|
|
225
|
-
### pushMany()
|
|
226
|
-
|
|
227
|
-
> **pushMany**(`items`): `number`
|
|
228
|
-
|
|
229
|
-
Enqueue multiple items in one call. Optimized to resize buffer once and
|
|
230
|
-
copy items in contiguous blocks when possible.
|
|
231
|
-
|
|
232
|
-
#### Parameters
|
|
233
|
-
|
|
234
|
-
##### items
|
|
235
|
-
|
|
236
|
-
`any`[]
|
|
237
|
-
|
|
238
|
-
#### Returns
|
|
239
|
-
|
|
240
|
-
`number`
|
|
241
|
-
|
|
242
|
-
New queue length after all pushes.
|
|
243
|
-
|
|
244
|
-
***
|
|
245
|
-
|
|
246
|
-
### shift()
|
|
247
|
-
|
|
248
|
-
> **shift**(): `any`
|
|
249
|
-
|
|
250
|
-
Dequeue and return the head item.
|
|
251
|
-
|
|
252
|
-
#### Returns
|
|
253
|
-
|
|
254
|
-
`any`
|
|
255
|
-
|
|
256
|
-
The dequeued item or `undefined` when empty.
|
|
257
|
-
|
|
258
|
-
***
|
|
259
|
-
|
|
260
|
-
### toArray()
|
|
261
|
-
|
|
262
|
-
> **toArray**(): `any`[]
|
|
263
|
-
|
|
264
|
-
Return a shallow array snapshot of the queue contents in FIFO order.
|
|
265
|
-
This is a convenience helper that does not consume the queue.
|
|
266
|
-
|
|
267
|
-
#### Returns
|
|
268
|
-
|
|
269
|
-
`any`[]
|
|
270
|
-
|
|
271
|
-
***
|
|
272
|
-
|
|
273
|
-
### unshiftMany()
|
|
274
|
-
|
|
275
|
-
> **unshiftMany**(`items`): `number`
|
|
276
|
-
|
|
277
|
-
Prepend multiple items to the head of the queue.
|
|
278
|
-
The first element of `items` will become the next value returned by `shift()`.
|
|
279
|
-
|
|
280
|
-
#### Parameters
|
|
281
|
-
|
|
282
|
-
##### items
|
|
283
|
-
|
|
284
|
-
`any`[]
|
|
285
|
-
|
|
286
|
-
#### Returns
|
|
287
|
-
|
|
288
|
-
`number`
|
|
289
|
-
|
|
290
|
-
New queue length after all unshifts.
|
|
291
|
-
|
|
292
|
-
***
|
|
293
|
-
|
|
294
|
-
### values()
|
|
295
|
-
|
|
296
|
-
> **values**(): `Iterator`\<`any`, `any`, `any`\>
|
|
297
|
-
|
|
298
|
-
Return an iterator of values (alias of the default iterator).
|
|
299
|
-
|
|
300
|
-
#### Returns
|
|
301
|
-
|
|
302
|
-
`Iterator`\<`any`, `any`, `any`\>
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
[**performance-helpers**](../../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[performance-helpers](../../README.md) / helpers/powerRateLimit
|
|
6
|
-
|
|
7
|
-
# helpers/powerRateLimit
|
|
8
|
-
|
|
9
|
-
## Classes
|
|
10
|
-
|
|
11
|
-
- [PowerRateLimit](classes/PowerRateLimit.md)
|
|
12
|
-
|
|
13
|
-
## References
|
|
14
|
-
|
|
15
|
-
### default
|
|
16
|
-
|
|
17
|
-
Renames and re-exports [PowerRateLimit](classes/PowerRateLimit.md)
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
[**performance-helpers**](../../../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[performance-helpers](../../../README.md) / [helpers/powerRateLimit](../README.md) / PowerRateLimit
|
|
6
|
-
|
|
7
|
-
# Class: PowerRateLimit
|
|
8
|
-
|
|
9
|
-
PowerRateLimit
|
|
10
|
-
|
|
11
|
-
Compose multiple rate limiters and provide a unified `tryConsume`/`reserve` API.
|
|
12
|
-
Returns success only when all underlying limiters allow consumption.
|
|
13
|
-
|
|
14
|
-
PowerRateLimit
|
|
15
|
-
|
|
16
|
-
## Constructors
|
|
17
|
-
|
|
18
|
-
### Constructor
|
|
19
|
-
|
|
20
|
-
> **new PowerRateLimit**(`limiters?`, `options?`): `PowerRateLimit`
|
|
21
|
-
|
|
22
|
-
#### Parameters
|
|
23
|
-
|
|
24
|
-
##### limiters?
|
|
25
|
-
|
|
26
|
-
`Object`[] = `[]`
|
|
27
|
-
|
|
28
|
-
Array of limiter instances implementing
|
|
29
|
-
`tryConsume(n)` and preferably `available()`.
|
|
30
|
-
|
|
31
|
-
##### options?
|
|
32
|
-
|
|
33
|
-
###### atomic?
|
|
34
|
-
|
|
35
|
-
`boolean`
|
|
36
|
-
|
|
37
|
-
When `true` attempt to provide
|
|
38
|
-
atomic semantics: either all limiters allow consumption or none will be
|
|
39
|
-
left mutated. This requires underlying limiters to expose `available()`
|
|
40
|
-
or an undo primitive (e.g. `reserve`/`release` or `addTokens`). If a
|
|
41
|
-
safe rollback cannot be guaranteed the call will return `false`.
|
|
42
|
-
|
|
43
|
-
#### Returns
|
|
44
|
-
|
|
45
|
-
`PowerRateLimit`
|
|
46
|
-
|
|
47
|
-
## Properties
|
|
48
|
-
|
|
49
|
-
### atomicDefault
|
|
50
|
-
|
|
51
|
-
> **atomicDefault**: `boolean`
|
|
52
|
-
|
|
53
|
-
***
|
|
54
|
-
|
|
55
|
-
### limiters
|
|
56
|
-
|
|
57
|
-
> **limiters**: `Object`[]
|
|
58
|
-
|
|
59
|
-
## Methods
|
|
60
|
-
|
|
61
|
-
### \_undoCommit()
|
|
62
|
-
|
|
63
|
-
> **\_undoCommit**(`entry`, `want`): `Promise`\<`any`\>
|
|
64
|
-
|
|
65
|
-
#### Parameters
|
|
66
|
-
|
|
67
|
-
##### entry
|
|
68
|
-
|
|
69
|
-
`any`
|
|
70
|
-
|
|
71
|
-
##### want
|
|
72
|
-
|
|
73
|
-
`any`
|
|
74
|
-
|
|
75
|
-
#### Returns
|
|
76
|
-
|
|
77
|
-
`Promise`\<`any`\>
|
|
78
|
-
|
|
79
|
-
***
|
|
80
|
-
|
|
81
|
-
### available()
|
|
82
|
-
|
|
83
|
-
> **available**(): `number`
|
|
84
|
-
|
|
85
|
-
Return the minimum available tokens across all limiters.
|
|
86
|
-
If any limiter does not expose `available()`, this returns `0`.
|
|
87
|
-
|
|
88
|
-
#### Returns
|
|
89
|
-
|
|
90
|
-
`number`
|
|
91
|
-
|
|
92
|
-
***
|
|
93
|
-
|
|
94
|
-
### release()
|
|
95
|
-
|
|
96
|
-
> **release**(`tokenOrN`): `void`
|
|
97
|
-
|
|
98
|
-
Release a prior reservation token or numeric count back to the limiters.
|
|
99
|
-
This accepts the same token object produced by `reserve()` or a numeric
|
|
100
|
-
count to return tokens directly.
|
|
101
|
-
|
|
102
|
-
#### Parameters
|
|
103
|
-
|
|
104
|
-
##### tokenOrN
|
|
105
|
-
|
|
106
|
-
`number` \| `object`
|
|
107
|
-
|
|
108
|
-
#### Returns
|
|
109
|
-
|
|
110
|
-
`void`
|
|
111
|
-
|
|
112
|
-
***
|
|
113
|
-
|
|
114
|
-
### reserve()
|
|
115
|
-
|
|
116
|
-
> **reserve**(`n?`): \{ `n`: `number`; \} \| `null`
|
|
117
|
-
|
|
118
|
-
Reserve `n` tokens across all limiters and return a token to undo later.
|
|
119
|
-
Returns `null` when reservation fails.
|
|
120
|
-
The returned token is a simple marker object such as `{ n: 1 }`, and it can
|
|
121
|
-
be consumed by `release(token)` or `rollback(token)` to restore the limiters.
|
|
122
|
-
|
|
123
|
-
#### Parameters
|
|
124
|
-
|
|
125
|
-
##### n?
|
|
126
|
-
|
|
127
|
-
`number` = `1`
|
|
128
|
-
|
|
129
|
-
#### Returns
|
|
130
|
-
|
|
131
|
-
\{ `n`: `number`; \} \| `null`
|
|
132
|
-
|
|
133
|
-
***
|
|
134
|
-
|
|
135
|
-
### reset()
|
|
136
|
-
|
|
137
|
-
> **reset**(): `void`
|
|
138
|
-
|
|
139
|
-
Reset all underlying limiters where supported.
|
|
140
|
-
|
|
141
|
-
#### Returns
|
|
142
|
-
|
|
143
|
-
`void`
|
|
144
|
-
|
|
145
|
-
***
|
|
146
|
-
|
|
147
|
-
### rollback()
|
|
148
|
-
|
|
149
|
-
> **rollback**(`nOrToken`): `void`
|
|
150
|
-
|
|
151
|
-
#### Parameters
|
|
152
|
-
|
|
153
|
-
##### nOrToken
|
|
154
|
-
|
|
155
|
-
`any`
|
|
156
|
-
|
|
157
|
-
#### Returns
|
|
158
|
-
|
|
159
|
-
`void`
|
|
160
|
-
|
|
161
|
-
***
|
|
162
|
-
|
|
163
|
-
### tryConsume()
|
|
164
|
-
|
|
165
|
-
> **tryConsume**(`n?`, `options?`): `boolean`
|
|
166
|
-
|
|
167
|
-
Try to consume `n` tokens across all limiters. Returns true only when
|
|
168
|
-
every underlying limiter allows consumption. This method first performs
|
|
169
|
-
a non-mutating availability check when `available()` is present; if all
|
|
170
|
-
checks pass it then performs the actual `tryConsume` calls to commit.
|
|
171
|
-
|
|
172
|
-
Note: when a limiter does not implement `available()` this method falls
|
|
173
|
-
back to calling `tryConsume` directly which may partially mutate state
|
|
174
|
-
if other limiters subsequently fail. Prefer limiters that implement
|
|
175
|
-
`available()` for atomic semantics.
|
|
176
|
-
|
|
177
|
-
#### Parameters
|
|
178
|
-
|
|
179
|
-
##### n?
|
|
180
|
-
|
|
181
|
-
`number` = `1`
|
|
182
|
-
|
|
183
|
-
##### options?
|
|
184
|
-
|
|
185
|
-
#### Returns
|
|
186
|
-
|
|
187
|
-
`boolean`
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
[**performance-helpers**](../../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[performance-helpers](../../README.md) / helpers/powerRetry
|
|
6
|
-
|
|
7
|
-
# helpers/powerRetry
|
|
8
|
-
|
|
9
|
-
## Classes
|
|
10
|
-
|
|
11
|
-
- [PowerRetry](classes/PowerRetry.md)
|
|
12
|
-
|
|
13
|
-
## References
|
|
14
|
-
|
|
15
|
-
### default
|
|
16
|
-
|
|
17
|
-
Renames and re-exports [PowerRetry](classes/PowerRetry.md)
|
|
18
|
-
|
|
19
|
-
***
|
|
20
|
-
|
|
21
|
-
### PowerRetryOptions
|
|
22
|
-
|
|
23
|
-
Re-exports [PowerRetryOptions](../jsdoc-types/interfaces/PowerRetryOptions.md)
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
[**performance-helpers**](../../../README.md)
|
|
2
|
-
|
|
3
|
-
***
|
|
4
|
-
|
|
5
|
-
[performance-helpers](../../../README.md) / [helpers/powerRetry](../README.md) / PowerRetry
|
|
6
|
-
|
|
7
|
-
# Class: PowerRetry
|
|
8
|
-
|
|
9
|
-
Retry helper with configurable backoff and jitter.
|
|
10
|
-
|
|
11
|
-
PowerRetry
|
|
12
|
-
|
|
13
|
-
## Example
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
const retry = new PowerRetry({ maxAttempts: 4, baseDelay: 50 });
|
|
17
|
-
const data = await retry.run(() => fetch('/api/data'));
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Constructors
|
|
21
|
-
|
|
22
|
-
### Constructor
|
|
23
|
-
|
|
24
|
-
> **new PowerRetry**(`options?`): `PowerRetry`
|
|
25
|
-
|
|
26
|
-
Run a function with retry/backoff semantics.
|
|
27
|
-
Create a configured retry helper.
|
|
28
|
-
|
|
29
|
-
#### Parameters
|
|
30
|
-
|
|
31
|
-
##### options?
|
|
32
|
-
|
|
33
|
-
[`PowerRetryOptions`](../../jsdoc-types/interfaces/PowerRetryOptions.md) = `{}`
|
|
34
|
-
|
|
35
|
-
Default options applied to every `run()` invocation.
|
|
36
|
-
|
|
37
|
-
#### Returns
|
|
38
|
-
|
|
39
|
-
`PowerRetry`
|
|
40
|
-
|
|
41
|
-
## Properties
|
|
42
|
-
|
|
43
|
-
### \_options
|
|
44
|
-
|
|
45
|
-
> **\_options**: [`PowerRetryOptions`](../../jsdoc-types/interfaces/PowerRetryOptions.md)
|
|
46
|
-
|
|
47
|
-
## Methods
|
|
48
|
-
|
|
49
|
-
### run()
|
|
50
|
-
|
|
51
|
-
> **run**(`fn`, `options?`): `Promise`\<`any`\>
|
|
52
|
-
|
|
53
|
-
Instance method that runs `fn` with the configured options merged with
|
|
54
|
-
any per-call `options` provided.
|
|
55
|
-
|
|
56
|
-
#### Parameters
|
|
57
|
-
|
|
58
|
-
##### fn
|
|
59
|
-
|
|
60
|
-
`Function`
|
|
61
|
-
|
|
62
|
-
Async function to execute.
|
|
63
|
-
|
|
64
|
-
##### options?
|
|
65
|
-
|
|
66
|
-
[`PowerRetryOptions`](../../jsdoc-types/interfaces/PowerRetryOptions.md) = `{}`
|
|
67
|
-
|
|
68
|
-
Per-call retry overrides.
|
|
69
|
-
|
|
70
|
-
#### Returns
|
|
71
|
-
|
|
72
|
-
`Promise`\<`any`\>
|
|
73
|
-
|
|
74
|
-
Resolves with `fn` result, rejects with final attempt error.
|
|
75
|
-
|
|
76
|
-
***
|
|
77
|
-
|
|
78
|
-
### run()
|
|
79
|
-
|
|
80
|
-
> `static` **run**(`fn`, `options?`): `Promise`\<`any`\>
|
|
81
|
-
|
|
82
|
-
Execute a function with retry/backoff semantics.
|
|
83
|
-
|
|
84
|
-
#### Parameters
|
|
85
|
-
|
|
86
|
-
##### fn
|
|
87
|
-
|
|
88
|
-
`Function`
|
|
89
|
-
|
|
90
|
-
Async function to execute.
|
|
91
|
-
|
|
92
|
-
##### options?
|
|
93
|
-
|
|
94
|
-
[`PowerRetryOptions`](../../jsdoc-types/interfaces/PowerRetryOptions.md) = `{}`
|
|
95
|
-
|
|
96
|
-
Retry behavior overrides for this invocation.
|
|
97
|
-
|
|
98
|
-
#### Returns
|
|
99
|
-
|
|
100
|
-
`Promise`\<`any`\>
|
|
101
|
-
|
|
102
|
-
Resolves with `fn` result, rejects with final attempt error.
|
|
103
|
-
|
|
104
|
-
#### Throws
|
|
105
|
-
|
|
106
|
-
When `fn` is not callable or `maxAttempts` is not a positive finite number.
|