Skip to content

Instantly share code, notes, and snippets.

@nadeesha
Created May 16, 2019 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nadeesha/3e3638392bc86396f51c4e17aef69b7b to your computer and use it in GitHub Desktop.
Save nadeesha/3e3638392bc86396f51c4e17aef69b7b to your computer and use it in GitHub Desktop.
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