Skip to content

feat: allow thunked objects to be spreadable#175

Merged
ivenmarquardt merged 2 commits into
robotroutine:masterfrom
monotykamary:patch-1
May 24, 2020
Merged

feat: allow thunked objects to be spreadable#175
ivenmarquardt merged 2 commits into
robotroutine:masterfrom
monotykamary:patch-1

Conversation

@monotykamary

Copy link
Copy Markdown
Contributor

Arrays returned in thunks can concatenated with the spread operator while objects cannot. This adds traps for ownKeys and getOwnPropertyDescriptor on ThunkProxy to allow non-iterable objects to be spreadable.

Arrays returned in thunks can concatenated with the spread operator while objects cannot. This adds traps for ownKeys and getOwnPropertyDescriptor on ThunkProxy to allow non-iterable objects to be spreadable.
@ivenmarquardt

ivenmarquardt commented May 22, 2020

Copy link
Copy Markdown
Contributor

Thanks for contributing! Spreadable thunked objects are useful, of course. However, before I merge this branch I have to take a closer look at your getOwnPropertyDescriptor trap, because it seems to convert every property to be an enumerable/configurable one, even if the wrapped object has non-enumerable ones. Maybe I am just confusing things, so please bear with me..

Preserve property descriptors in objects while still allowing them to be spreadable.
@monotykamary

monotykamary commented May 23, 2020

Copy link
Copy Markdown
Contributor Author

because it seems to convert every property to be an enumerable/configurable one, even if the wrapped object has non-enumerable ones

Oh, you're right. In that case, we can reflect the getOwnPropertyDescriptor to preserve descriptors.

I've pushed a new commit to 'reflect' this 😅. It will throw a TypeError if the proxy object is not configurable, which I haven't thought up a clean solution for 🤔.

@ivenmarquardt ivenmarquardt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@ivenmarquardt ivenmarquardt merged commit 1ae078b into robotroutine:master May 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants