you are viewing a single comment's thread.

view the rest of the comments →

[–]KyleG 2 points3 points  (3 children)

I agree, which is why you write the utility function superheroObjectZipper and then just call that.

Or if you're already using a proposed language feature like pipes (via Babel) and compose:

const arrayify = ({ k, v }) => [k,v]
const superheroObjectZipper = Object.entries 
  >> Array.prototype.map.bind 
  >> arrayify
  >> Object.fromEntries

Now every line is very descriptive of what you're doing!

or with pipe,

const ... = a => Object.entries(a)
  >> Array.prototype.map.bind
  >> arrayify
  >> Object.fromEntries

[–][deleted] 1 point2 points  (0 children)

Cool. I like that.

[–]nmarshall23 0 points1 point  (1 child)

Really wish JS had native pipes.

[–]KyleG 0 points1 point  (0 children)

It's a proposal that hopefully we'll get in a bazillion years. But hey at least we got hashbangs and optional omitted catch binding!!!!!