Skip to content

Support Holes in Array #41

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

Merged
merged 3 commits into from
Aug 29, 2020
Merged

Support Holes in Array #41

merged 3 commits into from
Aug 29, 2020

Conversation

kateinoigakukun
Copy link
Member

@kateinoigakukun kateinoigakukun commented Aug 28, 2020

Closes #39

@MaxDesiatov MaxDesiatov requested a review from j-f1 August 28, 2020 07:38

private func getObjectValuesLength(_ object: JSObject) -> Int {
let objectClass = JSObject.global.Object.function!
let values = objectClass.values!(object).object!
Copy link
Member

Choose a reason for hiding this comment

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

This won't work in another edge case — when there are additional properties added to the array (like doing array.foo = 'bar').

According to this post, running array.filter(() => true) removes the holes so that could be used to get a better count.

@MaxDesiatov MaxDesiatov requested a review from j-f1 August 28, 2020 15:21
@MaxDesiatov MaxDesiatov requested a review from j-f1 August 28, 2020 18:16
@kateinoigakukun kateinoigakukun merged commit c67bd51 into master Aug 29, 2020
@kateinoigakukun kateinoigakukun deleted the support-hole-in-array branch August 29, 2020 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for JS Arrays “holes”, including the test suite
2 participants