Skip to content

Instantly share code, notes, and snippets.

@crisu83
Last active April 3, 2021 16:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crisu83/60742a056bedcab639edeaa61fa48c9a to your computer and use it in GitHub Desktop.
Save crisu83/60742a056bedcab639edeaa61fa48c9a to your computer and use it in GitHub Desktop.
Simple strongly typed pipe function
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