DEV Community

Discussion on: Turboprop: JS Arrays as Property Accessors!?!

Collapse
 
robinpokorny profile image
Robin Pokorny

This is awesome. Love the thinking outside of box!

Quick comment, my expectation of this code was different. Instead of

console.log(obj[['b', 'c', 'e']])   // [6, 7, 9]
Enter fullscreen mode Exit fullscreen mode

I thought I'd get

console.log(obj[['b', 'c', 'e']])   // { b: 6, c: 7, e: 9 }
Enter fullscreen mode Exit fullscreen mode

That is more like _.pick instead of _.at (= R.props). I understand that it kind of breaks some of the combinations later.

It is possible to allow objects as properly accessors, but I think that would be cumbersome.

Collapse
 
jonrandy profile image
Jon Randy 🎖️

Yeah, I was torn between making the default behaviour do that, or what I ended up picking. One idea for the future is to make the behaviour switchable somehow

Collapse
 
jonrandy profile image
Jon Randy 🎖️

The library itself allows you to set it up how you like though