Skip to content

Instantly share code, notes, and snippets.

@rolandpeelen
Created July 22, 2018 18:50
Show Gist options
  • Select an option

  • Save rolandpeelen/d15e60df6fc73f211705e4f824830bfa to your computer and use it in GitHub Desktop.

Select an option

Save rolandpeelen/d15e60df6fc73f211705e4f824830bfa to your computer and use it in GitHub Desktop.
if value is true return function
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