Skip to content

Commit 108597e

Browse files
committed
Documentation and Tests refinements
1 parent 0a7e0bf commit 108597e

7 files changed

+73
-37
lines changed

dist/zero-backpressure-semaphore.d.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,14 @@ export declare class ZeroBackpressureSemaphore<T, UncaughtErrorType = Error> {
7474
/**
7575
* amountOfUncaughtErrors
7676
*
77-
* @returns The number of uncaught errors from background jobs, triggered by `startExecution`.
77+
* Indicates the number of uncaught errors from background jobs triggered by `startExecution`,
78+
* that are currently stored by the instance.
79+
* These errors have not yet been extracted using `extractUncaughtErrors`.
80+
*
81+
* Knowing the number of uncaught errors allows users to decide whether to process them immediately
82+
* or wait for further accumulation.
83+
*
84+
* @returns The number of uncaught errors from background jobs.
7885
*/
7986
get amountOfUncaughtErrors(): number;
8087
/**
@@ -127,14 +134,15 @@ export declare class ZeroBackpressureSemaphore<T, UncaughtErrorType = Error> {
127134
/**
128135
* waitForAllExecutingJobsToComplete
129136
*
130-
* This method allows the caller to wait until all currently executing jobs have completed.
131-
* It is useful for ensuring that the application can terminate gracefully, without leaving
132-
* any pending operations.
137+
* This method allows the caller to wait until all *currently* executing jobs have finished,
138+
* meaning once all running promises have either resolved or rejected.
139+
*
140+
* This is particularly useful in scenarios where you need to ensure that all jobs are completed
141+
* before proceeding, such as during shutdown processes or between unit tests.
133142
*
134-
* When this method is called, it returns a promise that resolves once all currently running
135-
* promises have either resolved or rejected. This is particularly useful in scenarios where
136-
* you need to ensure that all tasks are completed before proceeding, such as during shutdown
137-
* processes or between unit tests.
143+
* Note that the returned promise only awaits jobs that were executed at the time this method
144+
* was called. Specifically, it awaits all jobs initiated by this instance that had not completed
145+
* at the time of invocation.
138146
*
139147
* @returns A promise that resolves when all currently executing jobs are completed.
140148
*/
@@ -160,8 +168,8 @@ export declare class ZeroBackpressureSemaphore<T, UncaughtErrorType = Error> {
160168
* This method can be useful when the system is experiencing high load (as indicated by CPU and/or memory
161169
* usage metrics), and you want to pause further async operations until an available job slot opens up.
162170
* However, the same effect can be achieved with `startExecution` alone if the async logic
163-
* (which you intend to delay until availability) is performed *inside the job* rather than as a
164-
* preliminary step. Therefore, `waitForAvailability` is more of a design choice than a necessity.
171+
* (intended to be delayed until availability) is handled within the job itself rather than as a preliminary
172+
* step. Therefore, `waitForAvailability` serves as a design choice rather than a strict necessity.
165173
*
166174
* @returns A promise that resolves once at least one slot is available.
167175
*/

dist/zero-backpressure-semaphore.js

Lines changed: 18 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/zero-backpressure-semaphore.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/zero-backpressure-semaphore.test.js

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)