Last active
April 3, 2021 16:44
-
-
Save crisu83/60742a056bedcab639edeaa61fa48c9a to your computer and use it in GitHub Desktop.
Simple strongly typed pipe function
This file contains 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 OperatorFn<T> = (value: T) => T; | |
interface PipeFn { | |
<T>(...fns: OperatorFn<T>[]): (value: T) => T; | |
} | |
const pipe: PipeFn = (...fns) => value => | |
fns.reduce((val, fn) => fn(val), value); | |
export default pipe; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment