Function seqEarlyBreak

The same as seq but accepts a function that gets run after each error and using that erro decides if continue to try next functions.

seqEarlyBreak(
(e) => e.message === "important error",
() => { throw new Error("important error") }, () => 2, () => 3
) // throws given important error, does not run next functions
  • Type Parameters

    • T

    Parameters

    • earlyBreaker: undefined | SeqEarlyBreaker

      function that decides about early breaking the sequential run

    • Rest...args: SeqFunctions<T>

      functions to run, you can either pass them as many arguments or just single arguments with array

    Returns Promise<T>

    • whatever gets returned from given functions