Created
July 19, 2022 18:46
-
-
Save pbroschwitz/5d9e2f1be6365e21c54bd95e1309af0c to your computer and use it in GitHub Desktop.
Master FUNCTION OVERLOADS with 'compose' - example from Matt Pocock
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
// See https://www.youtube.com/watch?v=D1a8OoBWi1g&list=PLIvujZeVDLMx040-j1W4WFs1BxuTGdI_b&index=10 | |
function compose(...args: any[]) { | |
return {} as any; | |
} | |
const addOne = (a: number) => { | |
return a + 1; | |
} | |
const numToString = (a: number) => { | |
return a.toString(); | |
} | |
const stringToNum = (a: string) => { | |
return parseInt(a); | |
} | |
const addOneToString = compose(addOne); | |
// ^ <-- const addOneToString: any |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment