Runs given functions sequentially one by one, until any returns value. Supports async functions. Throws with new Error when every function throws.

seq(() => 1, () => 2, () => 3) // returns 1
seq(() => { throw new Error("1") }, () => 2, () => 3) // returns 2
seq(() => { throw new Error("1") }, () => { throw new Error("2") } }) // throws
  • Type Parameters

    • T

    Parameters

    • Rest...fns: 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