Global

Methods

doWhile(condition, thunk) → {Promise}

Asynchronous doWhile loop.

Parameters:
Name Type Description
condition function

Checks whether loop should continue or quit. ie: () => i < 10

thunk function

Loop body. Returns a Promise.

Source:
Returns:

Resolves if successful; otherwise rejects with error.

Type
Promise

for(initial, condition, update, thunk) → {Promise}

Asynchronous for loop.

Parameters:
Name Type Description
initial function

Sets up initial condition for loop. ie: () => i = 0

condition function

Checks whether loop body should be executed. ie: () => i < 10

update function

Executes after the loop body. ie: () => i++

thunk function

Loop body. Returns a Promise.

Source:
Returns:

Resolves if successful; otherwise rejects with error.

Type
Promise

map(items, thunk) → {Promise}

Asynchronous map. Each iteration is passed a the following: (items[index], index, items). Thunk should resolve a value, which will be stored in array that is built up each iteration. Index starts at 0 and is incremented each iteration. NOTE: modifying items will impact subsequent iterations.

Parameters:
Name Type Description
items Array.<object>

Collection to iterator over.

thunk function

Loop body. Returns a Promise.

Source:
Returns:

Resolves with array of values if successful; otherwise rejects with error.

Type
Promise

reduce(items, thunk, initialValueopt) → {Promise}

Asynchronous reduce. Each iteration is passed a the following: (accumulator, items[index], index, items). Thunk should resolve a value, which is used as accumulator input for next iteration. Index starts at 0 and is incremented each iteration. NOTE: modifying items will impact subsequent iterations.

Parameters:
Name Type Attributes Default Description
items Array.<object>

Collection to iterator over.

thunk function

Loop body. Returns a Promise and accepts a value.

initialValue object | number <optional>
0

Initial value for accumulator.

Source:
Returns:

Resolves with reduced value if successful; otherwise rejects with error.

Type
Promise

while(condition, thunk) → {Promise}

Asynchronous while loop.

Parameters:
Name Type Description
condition function

Checks whether loop body should be executed. ie: () => i < 10

thunk function

Loop body. Returns a Promise.

Source:
Returns:

Resolves if successful; otherwise rejects with error.

Type
Promise