Appearance
async
Functions
checkNoop()
ts
function checkNoop(): boolean;Defined in: src/async/checkNoop.ts:9
Default checkFn for async helpers that always allows continuation. Used when no custom check function is provided.
Returns
boolean
true – meaning the loop should continue.
Example
ts
checkNoop(); // => trueeachAsync()
ts
function eachAsync<A>(
collection,
iteratee,
ctx?,
checkFn?): Promise<A>;Defined in: src/async/eachAsync.ts:17
Chooses async iterator (forEach for arrays, forIn for objects) and runs it.
Type Parameters
| Type Parameter |
|---|
A extends any[] | Record<string, any> |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
collection | A | undefined | Array or object to iterate. |
iteratee | (this, value, key, collection) => any | undefined | Iteration function. |
ctx? | any | undefined | Optional this context. |
checkFn? | () => boolean | checkNoop | Optional function to additionally control loop continuation. |
Returns
Promise<A>
Promise resolved with the input collection after all items are processed.
Example
ts
await eachAsync([1, 2], async (v) => console.log(v)); // logs 1, 2eachParallel()
ts
function eachParallel<A>(
collection,
iteratee,
ctx?,
taskLimit?,
checkFn?): Promise<A>;Defined in: src/async/parallel/eachParallel.ts:19
Chooses parallel iterator (forEach for arrays, forIn for objects via forInParallel) and runs it. This is a thin facade mirroring the old JS behaviour.
Type Parameters
| Type Parameter |
|---|
A extends any[] | Record<string, any> |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
collection | A | undefined | Source array or object. |
iteratee | (this, value, key, collection) => any | undefined | Iteration function. |
ctx? | any | undefined | Optional this context. |
taskLimit? | number | undefined | Maximum number of concurrent tasks. |
checkFn? | () => boolean | checkNoop | Optional function to additionally control loop continuation. |
Returns
Promise<A>
Promise resolved with the input collection.
Example
ts
await eachParallel([1, 2, 3], async (v) => process(v), null, 2); // 2 concurrentfilterAsync()
ts
function filterAsync<T>(
items,
iteratee,
output,
ctx?,
checkFn?): Promise<T[]>;Defined in: src/async/filterAsync.ts:16
Asynchronously filters items using the provided iteratee.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
items | T[] | undefined | Source array-like collection. |
iteratee | (this, value, index, items) => any | undefined | Predicate function returning truthy/falsey or a promise. |
output | T[] | undefined | Optional array to push accepted items into. |
ctx? | any | undefined | Optional this context for the iteratee. |
checkFn? | () => boolean | checkNoop | Optional function to additionally control loop continuation. |
Returns
Promise<T[]>
Promise-like object resolved with the resulting array.
Example
ts
await filterAsync([1, 2, 3], async (v) => v > 1, null); // => [2, 3]filterInAsync()
ts
function filterInAsync<T>(
collection,
iteratee,
output?,
ctx?,
checkFn?): Promise<Record<string, T>>;Defined in: src/async/filterInAsync.ts:21
Asynchronous filter over array or object.
Unlike the legacy version, this helper expects iteratee to be a function; shorthand/normalize logic is removed.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
collection | Record<string, T> | undefined | Source object. |
iteratee | (this, value, key, collection) => any | undefined | Predicate function. |
output? | Record<string, T> | undefined | Optional output object. |
ctx? | any | undefined | Optional this context. |
checkFn? | () => boolean | checkNoop | Optional function to additionally control loop continuation. |
Returns
Promise<Record<string, T>>
Promise resolved with resulting object.
Example
ts
await filterInAsync({ a: 1, b: 2 }, async (v) => v > 1); // => { b: 2 }filterInParallel()
ts
function filterInParallel<T>(
collection,
iteratee,
output?,
ctx?,
taskLimit?,
checkFn?): Promise<Record<string, T>>;Defined in: src/async/parallel/filterInParallel.ts:21
Parallel asynchronous filter over object.
Expects iteratee to be a function; shorthand/normalize logic is removed.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
collection | Record<string, T> | undefined | Source object. |
iteratee | (this, value, key, collection) => any | undefined | Predicate function. |
output? | Record<string, T> | undefined | Optional output object. |
ctx? | any | undefined | Optional this context. |
taskLimit? | number | undefined | Maximum number of concurrent tasks. |
checkFn? | () => boolean | checkNoop | Optional function to additionally control loop continuation. |
Returns
Promise<Record<string, T>>
Promise resolved with resulting object.
Example
ts
await filterInParallel({ a: 1, b: 2 }, async (v) => v > 1, null, null, 2); // => { b: 2 }filterParallel()
ts
function filterParallel<T>(
items,
iteratee,
output,
ctx?,
taskLimit?,
checkFn?): Promise<T[]>;Defined in: src/async/parallel/filterParallel.ts:21
Parallel asynchronous filter over items.
First phase evaluates predicate in parallel and stores boolean flags, then reuses generic filterEach to build resulting array.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
items | T[] | undefined | Source array-like collection. |
iteratee | (this, value, index, items) => any | undefined | Predicate function. |
output | T[] | undefined | Optional output array. |
ctx? | any | undefined | Optional this context. |
taskLimit? | number | undefined | Maximum concurrent tasks. |
checkFn? | () => boolean | checkNoop | Optional function to additionally control loop continuation. |
Returns
Promise<T[]>
Promise resolved with resulting array.
Example
ts
await filterParallel([1, 2, 3], async (v) => v > 1, null, null, 2); // => [2, 3]findAsync()
ts
function findAsync<T>(
items,
iteratee,
ctx?,
checkFn?): Promise<T>;Defined in: src/async/findAsync.ts:15
Asynchronously finds first item that matches iteratee.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
items | T[] | undefined | Source array-like collection. |
iteratee | (this, value, index, items) => any | undefined | Predicate function returning truthy/falsey or a promise. |
ctx? | any | undefined | Optional this context for the iteratee. |
checkFn? | () => boolean | checkNoop | Optional function to additionally control loop continuation. |
Returns
Promise<T>
Promise-like object resolved with the found item or undefined.
Example
ts
await findAsync([1, 2, 3], async (v) => v === 2); // => 2findInAsync()
ts
function findInAsync<T>(
collection,
iteratee,
ctx?,
checkFn?): Promise<T>;Defined in: src/async/findInAsync.ts:18
Asynchronous find over array or object.
Expects iteratee to be a function; shorthand/normalize logic is removed.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
collection | Record<string, T> | undefined | Source array-like collection. |
iteratee | (this, value, key, collection) => any | undefined | Predicate function. |
ctx? | any | undefined | Optional this context. |
checkFn? | () => boolean | checkNoop | Optional function to additionally control loop continuation. |
Returns
Promise<T>
Promise resolved with the found item or undefined.
Example
ts
await findInAsync({ a: 1, b: 2 }, async (v) => v === 2); // => 2findInParallel()
ts
function findInParallel<T>(
collection,
iteratee,
ctx?,
taskLimit?,
checkFn?): Promise<T>;Defined in: src/async/parallel/findInParallel.ts:19
Parallel asynchronous find over object.
Expects iteratee to be a function; shorthand/normalize logic is removed.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
collection | Record<string, T> | undefined | Source object. |
iteratee | (this, value, key, collection) => any | undefined | Predicate function. |
ctx? | any | undefined | Optional this context. |
taskLimit? | number | undefined | Maximum number of concurrent tasks. |
checkFn? | () => boolean | checkNoop | Optional function to additionally control loop continuation. |
Returns
Promise<T>
Promise resolved with the found item or undefined.
Example
ts
await findInParallel({ a: 1, b: 2 }, async (v) => v === 2, null, 2); // => 2findParallel()
ts
function findParallel<T>(
items,
iteratee,
ctx?,
taskLimit?,
checkFn?): Promise<T>;Defined in: src/async/parallel/findParallel.ts:16
Parallel asynchronous find over array.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
items | T[] | undefined | Source array. |
iteratee | (this, value, index, items) => any | undefined | Predicate function. |
ctx? | any | undefined | Optional this context. |
taskLimit? | number | undefined | Maximum concurrent tasks. |
checkFn? | () => boolean | checkNoop | Optional function to additionally control loop continuation. |
Returns
Promise<T>
Promise resolved with the found item or undefined.
Example
ts
await findParallel([1, 2, 3], async (v) => v === 2, null, 2); // => 2forEachAsync()
ts
function forEachAsync<T>(
items,
iteratee,
ctx?,
checkFn?): Promise<T[]>;Defined in: src/async/forEachAsync.ts:15
Asynchronously iterates over an array-like items.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
items | T[] | undefined | Source array-like collection. |
iteratee | (this, value, index, items) => any | undefined | Iteration function, may return a value or a promise. |
ctx? | any | undefined | Optional this context for the iteratee. |
checkFn? | () => boolean | checkNoop | Optional function to additionally control loop continuation. |
Returns
Promise<T[]>
Promise resolved with the original items array when the loop completes.
Example
ts
await forEachAsync([1, 2], async (v) => console.log(v)); // logs 1, 2forEachParallel()
ts
function forEachParallel<T>(
items,
fn,
ctx?,
taskLimit?,
checkFn?): Promise<T[]>;Defined in: src/async/parallel/forEachParallel.ts:16
Parallel asynchronous forEach over array.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
items | T[] | undefined | Source array-like collection. |
fn | (this, value, index, items) => any | undefined | Iteration function. |
ctx? | any | undefined | Optional this context. |
taskLimit? | number | undefined | Maximum number of concurrent tasks. |
checkFn? | () => boolean | checkNoop | Optional function to additionally control loop continuation. |
Returns
Promise<T[]>
Promise resolved with the original items array.
Example
ts
await forEachParallel([1, 2, 3], async (v) => process(v), null, 2); // 2 concurrentforInAsync()
ts
function forInAsync<T>(
collection,
iteratee,
ctx?,
checkFn?): Promise<Record<string, T>>;Defined in: src/async/forInAsync.ts:16
Asynchronously iterates over object properties using entries.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
collection | Record<string, T> | undefined | Source object. |
iteratee | (this, value, key, collection) => any | undefined | - |
ctx? | any | undefined | Optional this context. |
checkFn? | () => boolean | checkNoop | Optional function to additionally control loop continuation. |
Returns
Promise<Record<string, T>>
Promise resolved with the original collection when the loop completes.
Example
ts
await forInAsync({ a: 1 }, async (v, k) => console.log(k, v)); // logs 'a', 1forInParallel()
ts
function forInParallel<T>(
collection,
fn,
ctx?,
taskLimit?,
checkFn?): Promise<Record<string, T>>;Defined in: src/async/parallel/forInParallel.ts:17
Parallel asynchronous iteration over object properties.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
collection | Record<string, T> | undefined | Source object. |
fn | (this, value, key, collection) => any | undefined | Iteration function receiving (value, key, collection). |
ctx? | any | undefined | Optional this context. |
taskLimit? | number | undefined | Maximum number of concurrent tasks. |
checkFn? | () => boolean | checkNoop | Optional function to additionally control loop continuation. |
Returns
Promise<Record<string, T>>
Promise resolved with the resulting object.
Example
ts
await forInParallel({ a: 1, b: 2 }, async (v, k) => process(k, v), null, 2);intervalAsync()
ts
function intervalAsync(
fn,
delayMs?,
args?,
self?): () => void;Defined in: src/async/intervalAsync.ts:20
Runs fn periodically with the given delay.
If fn returns a promise, the next tick is scheduled after it settles. Returns a cancel function that stops subsequent executions.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
fn | (...args) => any | undefined | Function to execute periodically. |
delayMs | number | 0 | Delay in milliseconds. |
args? | ArrayLike<any> | undefined | Arguments to pass to the function. |
self? | any | undefined | Optional this context. |
Returns
A cancel function that stops subsequent executions.
() => void
Example
ts
const stop = intervalAsync(() => fetch('/ping'), 5000);
stop(); // cancels further executionsloopAsync()
ts
function loopAsync(checkFn, statementFn): Promise<void>;Defined in: src/async/loopAsync.ts:13
Asynchronous loop helper that repeatedly calls statementFn while checkFn is true.
Parameters
| Parameter | Type | Description |
|---|---|---|
checkFn | () => boolean | Function to check if the loop should continue. |
statementFn | () => any | Function to execute on each iteration. |
Returns
Promise<void>
Promise resolved when the loop completes.
Example
ts
let i = 0;
await loopAsync(() => i < 3, async () => { i++; }); // i === 3loopParallel()
ts
function loopParallel(
checkFn,
statementFn,
taskLimit?): Promise<any[]>;Defined in: src/async/parallel/loopParallel.ts:17
Runs statementFn in parallel with a maximum of taskLimit concurrent tasks, advancing while checkFn returns true.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
checkFn | () => boolean | undefined | Function to check if the loop should continue. |
statementFn | () => any | undefined | Function to execute on each iteration. |
taskLimit | number | 1 | Maximum number of concurrent tasks. |
Returns
Promise<any[]>
Promise resolved when the loop completes.
Example
ts
let i = 0;
await loopParallel(() => i < 6, async () => { i++; }, 3); // 3 concurrent tasksmapAsync()
ts
function mapAsync<T, R>(
items,
iteratee,
ctx?,
checkFn?): Promise<R[]>;Defined in: src/async/mapAsync.ts:15
Asynchronously maps an array-like items using iteratee.
Type Parameters
| Type Parameter |
|---|
T |
R |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
items | T[] | undefined | Source array-like collection. |
iteratee | (this, value, index, items) => R | Promise<R> | undefined | Mapping function, may return a value or a promise. |
ctx? | any | undefined | Optional this context for the iteratee. |
checkFn? | () => boolean | checkNoop | Optional function to additionally control loop continuation. |
Returns
Promise<R[]>
Promise resolved with the resulting array.
Example
ts
await mapAsync([1, 2], async (v) => v * 2); // => [2, 4]mapInAsync()
ts
function mapInAsync<T>(
collection,
iteratee,
ctx?,
checkFn?): Promise<Record<string, T>>;Defined in: src/async/mapInAsync.ts:19
Asynchronous map over object.
Expects iteratee to be a function; shorthand/normalize logic is removed.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
collection | Record<string, T> | undefined | Source object. |
iteratee | (this, value, key, collection) => T | Promise<T> | undefined | Mapping function. |
ctx? | any | undefined | Optional this context. |
checkFn? | () => boolean | checkNoop | Optional function to additionally control loop continuation. |
Returns
Promise<Record<string, T>>
Promise resolved with resulting object.
Example
ts
await mapInAsync({ a: 1 }, async (v) => v * 2); // => { a: 2 }mapInParallel()
ts
function mapInParallel<T>(
collection,
iteratee,
ctx?,
taskLimit?,
checkFn?): Promise<Record<string, T>>;Defined in: src/async/parallel/mapInParallel.ts:18
Parallel asynchronous map over array or object.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
collection | Record<string, T> | undefined | Source object. |
iteratee | (this, value, key, collection) => T | Promise<T> | undefined | Mapping function. |
ctx? | any | undefined | Optional this context. |
taskLimit? | number | undefined | Maximum number of concurrent tasks. |
checkFn? | () => boolean | checkNoop | Optional function to additionally control loop continuation. |
Returns
Promise<Record<string, T>>
Promise resolved with resulting object.
Example
ts
await mapInParallel({ a: 1, b: 2 }, async (v) => v * 2, null, 2); // => { a: 2, b: 4 }mapParallel()
ts
function mapParallel<T, R>(
items,
iteratee,
ctx?,
taskLimit?,
checkFn?): Promise<R[]>;Defined in: src/async/parallel/mapParallel.ts:16
Parallel asynchronous map over items.
Type Parameters
| Type Parameter |
|---|
T |
R |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
items | T[] | undefined | Source array-like collection. |
iteratee | (this, value, index, items) => R | Promise<R> | undefined | Mapping function, may return a value or a promise. |
ctx? | any | undefined | Optional this context for the iteratee. |
taskLimit? | number | undefined | Maximum number of concurrent tasks. |
checkFn? | () => boolean | checkNoop | Optional function to additionally control loop continuation. |
Returns
Promise<R[]>
Promise resolved with resulting array.
Example
ts
await mapParallel([1, 2, 3], async (v) => v * 2, null, 2); // => [2, 4, 6]reduceAsync()
ts
function reduceAsync<T, A>(
items,
iteratee,
accumulator,
ctx?,
checkFn?): Promise<A>;Defined in: src/async/reduceAsync.ts:18
Asynchronously reduces an array-like items from left to right.
Expects iteratee to be a function; shorthand/normalize logic is removed.
Type Parameters
| Type Parameter |
|---|
T |
A |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
items | T[] | undefined | Source array-like collection. |
iteratee | (this, acc, value, index, items) => A | Promise<A> | undefined | Reducer function, may return a value or a promise. |
accumulator | A | undefined | Initial accumulator value. |
ctx? | any | undefined | Optional this context for the iteratee. |
checkFn? | () => boolean | checkNoop | Optional function to additionally control loop continuation. |
Returns
Promise<A>
Promise resolved with the final accumulator.
Example
ts
await reduceAsync([1, 2, 3], async (acc, v) => acc + v, 0); // => 6reduceInAsync()
ts
function reduceInAsync<T, A>(
collection,
iteratee,
accumulator,
ctx?,
checkFn?): Promise<A>;Defined in: src/async/reduceInAsync.ts:19
Asynchronous reduce over object.
Expects iteratee to be a function; shorthand/normalize logic is removed.
Type Parameters
| Type Parameter |
|---|
T |
A |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
collection | Record<string, T> | undefined | Array or object to reduce. |
iteratee | (this, acc, value, key, collection) => A | Promise<A> | undefined | Async-friendly reducer function. |
accumulator | A | undefined | Initial accumulator value. |
ctx? | any | undefined | Optional this context for the iteratee. |
checkFn? | () => boolean | checkNoop | Optional function to additionally control loop continuation. |
Returns
Promise<A>
Promise resolved with the final accumulator.
Example
ts
await reduceInAsync({ a: 1, b: 2 }, async (acc, v) => acc + v, 0); // => 3reduceInParallel()
ts
function reduceInParallel<T, A>(
collection,
iteratee,
accumulator,
ctx?,
taskLimit?,
checkFn?): Promise<A>;Defined in: src/async/parallel/reduceInParallel.ts:18
Parallel asynchronous reduce over array or object.
Type Parameters
| Type Parameter |
|---|
T |
A |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
collection | Record<string, T> | undefined | Source object. |
iteratee | (this, acc, value, key, collection) => A | Promise<A> | undefined | Reducer function. |
accumulator | A | undefined | Initial accumulator value. |
ctx? | any | undefined | Optional this context for the iteratee. |
taskLimit? | number | undefined | Maximum number of concurrent tasks. |
checkFn? | () => boolean | checkNoop | Optional function to additionally control loop continuation. |
Returns
Promise<A>
Promise resolved with the final accumulator.
Example
ts
await reduceInParallel({ a: 1, b: 2 }, async (acc, v) => acc + v, 0, null, 2); // => 3reduceParallel()
ts
function reduceParallel<T, A>(
input,
iteratee,
accumulator,
ctx?,
taskLimit?,
checkFn?): Promise<A>;Defined in: src/async/parallel/reduceParallel.ts:19
Parallel asynchronous reduce over an array-like input.
Iterations are scheduled in parallel with a configurable taskLimit.
Type Parameters
| Type Parameter |
|---|
T |
A |
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
input | T[] | undefined | Source array-like collection. |
iteratee | (this, acc, value, index, input) => A | Promise<A> | undefined | Function called for each item. |
accumulator | A | undefined | Initial accumulator value. |
ctx? | any | undefined | Optional this context for the iteratee. |
taskLimit? | number | undefined | Maximum number of concurrent tasks. |
checkFn? | () => boolean | checkNoop | Optional function to additionally control loop continuation. |
Returns
Promise<A>
A promise resolved with the final accumulator.
Example
ts
await reduceParallel([1, 2, 3], async (acc, v) => acc + v, 0, null, 2); // => 6sequence()
ts
function sequence<T>(fn, ctx?): (...args) => Promise<ReturnType<T>>;Defined in: src/async/sequence.ts:13
Wraps function so that calls are executed sequentially: each waits for the previous.
Type Parameters
| Type Parameter |
|---|
T extends (...args) => any |
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | T | Function to wrap. |
ctx? | any | Optional this context for the function. |
Returns
Wrapped function that returns a Promise.
(...args) => Promise<ReturnType<T>>
Example
ts
const seq = sequence(fetchData);
seq(); // first call starts immediately
seq(); // waits for first to finish, then runssequenceDelay()
ts
function sequenceDelay<T>(
fn,
delayMs,
ctx?): (...args) => Promise<ReturnType<T>>;Defined in: src/async/sequenceDelay.ts:15
Like sequence, but adds a delay before each execution.
Type Parameters
| Type Parameter |
|---|
T extends (...args) => any |
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | T | Function to wrap. |
delayMs | number | Delay in milliseconds. |
ctx? | any | Optional this context for the function. |
Returns
Wrapped function that returns a Promise.
(...args) => Promise<ReturnType<T>>
Example
ts
const delayedSave = sequenceDelay(save, 300);
delayedSave(); // waits 300ms before executing, queues subsequent callswithDelayAsync()
ts
function withDelayAsync<T>(
fn,
delayMs,
ctx?): (...args) => Promise<ReturnType<T>>;Defined in: src/async/withDelayAsync.ts:13
Debounced async wrapper: schedules function execution after delayMs. Returns a promise resolved with the last call result.
Type Parameters
| Type Parameter |
|---|
T extends (...args) => any |
Parameters
| Parameter | Type | Description |
|---|---|---|
fn | T | Function to wrap. |
delayMs | number | Delay in milliseconds. |
ctx? | any | Optional this context for the function. |
Returns
Wrapped debounced function that returns a Promise.
(...args) => Promise<ReturnType<T>>
Example
ts
const debounced = withDelayAsync(search, 300);
debounced('query'); // => Promise, resolves after 300mswithLatencyProvider()
ts
function withLatencyProvider(requestLatency): <T>(fn, args, ctx) => Promise<T>;Defined in: src/async/withLatencyProvider.ts:15
Ensures that calls to fn take at least requestLatency ms. Useful for smoothing UI latency so fast responses don't cause visual flicker.
Parameters
| Parameter | Type | Description |
|---|---|---|
requestLatency | number | Minimum response time in milliseconds. |
Returns
A function that runs fn with the given minimum latency.
<T>(fn, args, ctx) => Promise<T>
Example
ts
const run = withLatencyProvider(500);
await run(fetchData, [], ctx); // always takes at least 500ms