Created
May 18, 2016 11:59
-
-
Save stoeffel/5561124c380a8313548f809111c5905a 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
const l = console::console.log | |
const safeProp = prop => R.compose(S.toMaybe, R.prop(prop)) | |
const withDefault = R.curry((def, safeFun) => (...args) => { | |
const maybe = safeFun(...args) | |
return S.maybe(def, R.identity, maybe) | |
}) | |
const name = withDefault('anon', safeProp('name')) | |
l(name({name: 'foo'})) | |
l(name({nope: 'foo'})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment