| addErrorHandler | Adds an error handler to a Promise that catches any errors and emits an async error event. |
| asyncFilter | Filters an array asynchronously, keeping only the elements that satisfy the provided predicate function. |
| asyncFilterInPlace | Filters an array asynchronously in place, keeping only the elements that satisfy the provided predicate function. |
| asyncFlatMap | Maps over an array asynchronously, applying the provided callback function to each element, and then flattens the results into a single array. |
| asyncMap | Maps over an array asynchronously, applying the provided callback function to each element. |
| chain | Chains a promise with another promise. |
| convertAsyncToSync | Converts an asynchronous function to a synchronous one by automatically handling the Promise rejection. |
| convertSyncToAsync | Converts a synchronous function to an asynchronous one by wrapping it in a Promise. |
| disableAsyncOperationTracking | Disables tracking previously enabled via enableAsyncOperationTracking and forgets any currently-tracked operations. |
| enableAsyncOperationTracking | Enables tracking of fire-and-forget operations scheduled via invokeAsyncSafely (and therefore convertAsyncToSync). While enabled, each scheduled operation is recorded until it settles so that tests can await them all via waitForAllAsyncOperations, removing the need to override invokeAsyncSafely / convertAsyncToSync in tests. Tracking is disabled by default, so production code carries no bookkeeping overhead. Intended to be enabled in test environments only. |
| handleSilentError | Handles a silent error. |
| ignoreError | Ignores an error that is thrown by an asynchronous function. |
| invokeAsyncSafely | Invokes a Promise and safely handles any errors by catching them and emitting an async error event. |
| invokeAsyncSafelyAfterDelay | Invokes an asynchronous function after a delay. |
| isAsyncOperationTrackingEnabled | Checks whether async-operation tracking is currently enabled (see enableAsyncOperationTracking). |
| marksAsTerminateRetry | Marks an error to terminate retry logic. |
| neverEnds | An async function that never ends. |
| nextTickAsync | Gets the next tick. |
| normalizePromisable | Converts to native promisable, converting PromiseLike (aka Thenable) to a native Promise. |
| promiseAllAsyncFnsSequentially | Executes async functions sequentially. |
| promiseAllSequentially | Executes promises sequentially. |
| queueMicrotaskAsync | Gets the next queue microtask. |
| requestAnimationFrameAsync | Gets the next request animation frame. |
| retryWithTimeout | Retries the provided function until it returns true or the timeout is reached. |
| runWithTimeout | Executes a function with a timeout. If the function does not complete within the specified time, it is considered to have timed out. If DEBUG=obsidian-dev-utils:Async:runWithTimeout is set, the execution is not terminated after the timeout and the function is allowed to run indefinitely. |
| setImmediateAsync | Gets the next set immediate. |
| setTimeoutAsync | Delays execution for a specified number of milliseconds. |
| sleep | Delays execution for a specified number of milliseconds. |
| timeout | Returns a Promise that rejects after the specified timeout period. |
| toArray | Converts an AsyncIterableIterator to an array by consuming all its elements. |
| waitForAllAsyncOperations | Waits for all fire-and-forget operations tracked since enableAsyncOperationTracking was called to settle. Operations scheduled while awaiting are also awaited, so cascading fire-and-forget chains are fully drained. |