Created
July 22, 2018 18:50
-
-
Save rolandpeelen/d15e60df6fc73f211705e4f824830bfa to your computer and use it in GitHub Desktop.
if value is true return function
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
| import {curry} from "ramda"; | |
| // Take a function and a value, return the function with the applied value if the value is evaluated as true | |
| const falseOr = curry((fn, value) => value && fn(value)); | |
| // Return a string that indicates loading | |
| const loadingString = () => '…'; | |
| // Return the loading string but only if the input evaluates to true | |
| const loadingStringIf = falseOr(loadingString); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment