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?
