Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add array grouping proposal #959

Merged
merged 4 commits into from Jul 29, 2021
Merged

Add array grouping proposal #959

merged 4 commits into from Jul 29, 2021

Conversation

@zloirock
Copy link
Owner

@zloirock zloirock commented Jul 15, 2021

https://github.com/tc39/proposal-array-grouping

@zloirock
Copy link
Owner Author

@zloirock zloirock commented Jul 17, 2021

@jridgewell could you review it?

Loading

@zloirock zloirock force-pushed the array-grouping branch 7 times, most recently from 04457e2 to 4c1f476 Jul 19, 2021
key = toPropertyKey(boundFunction(value, index, O));
// in some IE10 builds, `hasOwnProperty` returns incorrect result on integer keys
// but since it's a `null` prototype object, we can safely use `in`
if (key in target) push.call(target[key], value);

Choose a reason for hiding this comment

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

Nit: I switched a List type in the current spec, but I don't know how you implement list (it may just be a normal array?) But I think this exposes set operations in an incorrect order?

Loading

Copy link
Owner Author

@zloirock zloirock Jul 28, 2021

Choose a reason for hiding this comment

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

Lists are unobservable, so it's optimized for direct adding plain arrays to the null prototype object. If it's a custom array constructor or a typed array, they are created on a second loop pass and all observable operations evaluated in the correct order. The only observable difference with the current spec draft is an optimization of getting @@species constructor.

Loading

Copy link
Owner Author

@zloirock zloirock Jul 28, 2021

Choose a reason for hiding this comment

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

Sure, it's possible to define setters on Array.prototype or Object.prototype and observe it, but I think that it's an acceptable limitation. This is a limitation of all polyfills of features that use List that I know. It's possible to use arrays with null prototype or objects with null prototype, but I don't think that it's worth it.

Loading

@zloirock zloirock merged commit ac93365 into master Jul 29, 2021
14 checks passed
Loading
@zloirock zloirock deleted the array-grouping branch Jul 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants