@celo/base"async"

Module: "async"

Index

Functions

Functions

concurrentMap

concurrentMap<A, B>(concurrency: number, xs: A[], mapFn: function): Promise‹B[]›

Defined in packages/sdk/base/src/async.ts:128

Map an async function over a list xs with a given concurrency level

Type parameters:

A

B

Parameters:

concurrency: number

number of mapFn concurrent executions

xs: A[]

list of value

mapFn: function

mapping function

▸ (val: A, idx: number): Promise‹B›

Parameters:

Name Type
val A
idx number

Returns: Promise‹B[]›


concurrentValuesMap

concurrentValuesMap<IN, OUT>(concurrency: number, x: Record‹string, IN›, mapFn: function): Promise‹Record‹string, OUT››

Defined in packages/sdk/base/src/async.ts:150

Map an async function over the values in Object x with a given concurrency level

Type parameters:

IN: any

OUT: any

Parameters:

concurrency: number

number of mapFn concurrent executions

x: Record‹string, IN›

associative array of values

mapFn: function

mapping function

▸ (val: IN, key: string): Promise‹OUT›

Parameters:

Name Type
val IN
key string

Returns: Promise‹Record‹string, OUT››


Const retryAsync

retryAsync<T, U>(inFunction: InFunction‹T, U›, tries: number, params: T, delay: number, logger: Logger | null): Promise‹U›

Defined in packages/sdk/base/src/async.ts:14

Type parameters:

T: any[]

U

Parameters:

Name Type Default
inFunction InFunction‹T, U› -
tries number -
params T -
delay number 100
logger Logger | null null

Returns: Promise‹U›


Const retryAsyncWithBackOff

retryAsyncWithBackOff<T, U>(inFunction: InFunction‹T, U›, tries: number, params: T, delay: number, factor: number, logger: Logger | null): Promise‹U›

Defined in packages/sdk/base/src/async.ts:40

Type parameters:

T: any[]

U

Parameters:

Name Type Default
inFunction InFunction‹T, U› -
tries number -
params T -
delay number 100
factor number 1.5
logger Logger | null null

Returns: Promise‹U›


Const retryAsyncWithBackOffAndTimeout

retryAsyncWithBackOffAndTimeout<T, U>(inFunction: InFunction‹T, U›, tries: number, params: T, delayMs: number, factor: number, timeoutMs: number, logger: Logger | null): Promise‹U›

Defined in packages/sdk/base/src/async.ts:102

Type parameters:

T: any[]

U

Parameters:

Name Type Default
inFunction InFunction‹T, U› -
tries number -
params T -
delayMs number 100
factor number 1.5
timeoutMs number 2000
logger Logger | null null

Returns: Promise‹U›


Const selectiveRetryAsyncWithBackOff

selectiveRetryAsyncWithBackOff<T, U>(inFunction: InFunction‹T, U›, tries: number, dontRetry: string[], params: T, delay: number, factor: number, logger: Logger | null): Promise‹U›

Defined in packages/sdk/base/src/async.ts:68

Type parameters:

T: any[]

U

Parameters:

Name Type Default
inFunction InFunction‹T, U› -
tries number -
dontRetry string[] -
params T -
delay number 100
factor number 1.5
logger Logger | null null

Returns: Promise‹U›


sleep

sleep(ms: number): Promise‹void›

Defined in packages/sdk/base/src/async.ts:6

Sleep for a number of milliseconds

Parameters:

Name Type
ms number

Returns: Promise‹void›


Const timeout

timeout<T, U>(inFunction: InFunction‹T, U›, params: T, timeoutMs: number, timeoutError: any, timeoutLogMsg: string | null, logger: Logger | null): Promise‹U›

Defined in packages/sdk/base/src/async.ts:173

Wraps an async function in a timeout before calling it.

Type parameters:

T: any[]

U

Parameters:

Name Type Default Description
inFunction InFunction‹T, U› - The async function to call
params T - The parameters of the async function
timeoutMs number - The timeout in milliseconds
timeoutError any - The value to which the returned Promise should reject to
timeoutLogMsg string | null null -
logger Logger | null null -

Returns: Promise‹U›