/** * Iterate over an iterable and run a closure on each item - as with `for ... of` - but do so * asynchronously and with minimal waits inserted after a configurable time interval. * * Intended for long-running or compute-intensive loops that would otherwise lock up the browser * if run synchronously. Waiting at regular intervals minimizes blocking of user interactions, * allowing ongoing rendering of UI updates (e.g. load masks) and generally keeping the browser * event loop running. * * Note that if the content tab is hidden (i.e. `!XH.pageIsVisible`) this loop will be executed * without pauses. In this case the pauses would be unduly large due to throttling of the event * loop by the browser, and there is no user benefit to avoiding blocking the main thread. * * NOTE this is NOT for use cases where the `fn` arg is itself async - i.e. it does not await the * call to `fn` and is instead for the opposite use case, where fn is *synchronous*. If looking to * run an async operation over a collection, consider a simple and blocking for...of loop. */ export declare function forEachAsync(collection: Iterable, fn: (val: T, idx: number, collection: Iterable) => void, opts?: { waitAfter?: number; waitFor?: number; }): Promise; /** * As with `forEachAsync()` above, but in the form of a `while` loop. * @param conditionFn - called before each iteration; return true to continue loop. * @param fn - called without arguments for each iteration. * @param opts - additional options. */ export declare function whileAsync(conditionFn: () => boolean, fn: () => void, opts?: AsyncLoopOptions): Promise; export interface AsyncLoopOptions { /** * Interval in ms after which the loop should pause and wait. If the loop completes before * this interval has passed, no waits will be inserted. Default 50ms. */ waitAfter?: number; /** * Wait time in ms for each pause. The default of 0ms should be sufficient to allow an event * loop cycle to run. */ waitFor?: number; }