Created
October 6, 2019 19:23
-
-
Save justinobney/e6115bfba404a2876ff4f61eb56df088 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type composeFn<T> = (x: T) => T | Promise<T>; | |
function compose<T>(...fns: composeFn<T>[]) { | |
return async (x: T | Promise<T>): Promise<T> => | |
fns.reduce((v, f) => (async () => f(await v))(), x); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment