External module "promise/try-one-by-one" Functions tryOneByOne tryOneByOne<T>( promises: Array < Promise < T > | function > ) : Promise < T > Type parameters Parameters promises: Array < Promise < T > | function > Returns Promise < T > Legend Module Object literal Variable Function Function with type parameter Index signature Type alias Type alias with type parameter Enumeration Enumeration member Property Method Interface Interface with type parameter Constructor Property Method Index signature Class Class with type parameter Constructor Property Method Accessor Index signature Inherited constructor Inherited property Inherited method Inherited accessor Protected property Protected method Protected accessor Private property Private method Private accessor Static property Static method
Try One By One
Tries a set of promises one by one with given order. Breaks the call when a promise resolved. Otherwise keeps trying incoming promises until the list is finished.
Example:
import { tryOneByOne } from "@thalesrc/js-utils/promise"; async function fooFunction() { const foo = await tryOneByOne([ () => someCall(), (err) => anotherCall(), (err) => fooPromise() ]); // do stuff }Static Example:
import "@thalesrc/js-utils/promise/static/try-one-by-one"; async function fooFunction() { const foo = await Promise.tryOneByOne([ () => someCall(), (err) => anotherCall(), (err) => fooPromise() ]); // do stuff }