Eric R. Shinn
Sep 5, 2018 · 1 min read

Oh jazz.. I’d been using ternaries in API responses as in:

const someComponent = ({
shallowObj,
deepObj
}) => ({
shallowObj
? shallowObj
: {},
deepObj
? Object.assign({}, ...Object.keys(deepObj)
.map(key => ({[key]: `${deepObj[key]} & junk.`}))
: {},
})

…curried by another method that removed the empty {} & [] like:

const resObj = {}
const append = appender(resObj)
return promiseBasedMethod
.then(append(someComponent))

This is going to clean up someComponent hella much. Where you get such sorcery?

    Eric R. Shinn

    Written by

    Creative Developer ∾ Logical Designer

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade