Methods

inner

best(promises) → Promise

Given N promises will return the fastest non-failed one. This pattern can be useful some times to reduce latency.

Example

await best([Promise.resolve(1),Promise.resolve(2)]) // -> 1 (assuming 1 is the first to resolve)
await best([Promise.reject(1),Promise.resolve(2)]) // -> 2

Parameter

Name Type Optional Description

promises

Array(Promise)

 

An array of all promises to be executed

See also

When Do Redundant Requests Reduce Latency?

Rob-Pike

concurrencyTest.js

Returns

Promise 

inner

full(promises) → Array(Object)

A Promise.all that does not fails-fast. Given N promises will return all of them independenly if they failed or not.

Example

await full([Promise.resolve(1), Promise.reject(2), Promise.resolve(3)])
// [ { value: 1 }, { error: 2 }, { value: 3 } ]

Parameter

Name Type Optional Description

promises

Array(Promise)

 

An array of all promises to be executed

See also

Fail-fast

Rob-Pike

concurrencyTest.js

concurrencyTest.js

Returns

Array(Object)