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 Copy
seq(() => 1, () => 2, () => 3) // returns 1
seq(() => { throw new Error("1") }, () => 2, () => 3) // returns 2 Copy
seq(() => { throw new Error("1") }, () => 2, () => 3) // returns 2
seq(() => { throw new Error("1") }, () => { throw new Error("2") } }) // throws Copy
seq(() => { throw new Error("1") }, () => { throw new Error("2") } }) // throws
Rest
functions to run, you can either pass them as many arguments or just single arguments with array
Runs given functions sequentially one by one, until any returns value. Supports async functions. Throws with new Error when every function throws.
Example
Example
Example