Skip to content

Instantly share code, notes, and snippets.

@estrattonbailey
Created June 26, 2017 18:25
Show Gist options
  • Save estrattonbailey/10223b66d64ff9395b37c984c45adcbe to your computer and use it in GitHub Desktop.
Save estrattonbailey/10223b66d64ff9395b37c984c45adcbe to your computer and use it in GitHub Desktop.
CX
const triage = obj => Object.keys(obj).reduce((res, key) => {
res += !!(obj[key]) ? ` ${key}` : ''
return res
}, ' ')
const cx = (...args) => args.reduce((res, arg) => {
res += typeof arg === 'string' ? ` ${arg}` : triage(arg)
return res
}, ' ').trim().replace(/\s\s/, ' ')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment