Created
May 16, 2019 22:52
-
-
Save nadeesha/3e3638392bc86396f51c4e17aef69b7b 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
export const conditionally = <Props, Result>(options: { | |
if: (props: Props) => any; | |
then: (props: Props) => Result | Result; | |
else: (props: Props) => Result | Result; | |
}) => (props: Props) => { | |
return options.if(props) ? options.then(props) : options.else(props); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment