Enum Shorthand
const toEnum = (...values) =>
Object.freeze(values.reduce((acc, curr) => {
acc[curr] = curr
return acc
}, {}))
const Graphics = toEnum(
'circle',
'rect',
'triangle'
)
console.log(Graphics.circle)
I sure dislike fake enums in js. Something like this at least dries things up – but still, yuk! 😀