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

Implement Iterator.prototype.some #627

Merged
merged 1 commit into from
Oct 25, 2024
Merged

Implement Iterator.prototype.some #627

merged 1 commit into from
Oct 25, 2024

Conversation

saghul
Copy link
Contributor

@saghul saghul commented Oct 25, 2024

No description provided.

@saghul
Copy link
Contributor Author

saghul commented Oct 25, 2024

Alright, this is the last of the straightforward ones. The remaining ones: map, filter, take, drop, flatMap require creating a wrapping iterator AFAIS. Any pointers on how to go about it are most welcome! Perhaps we need a helper class a la async-from-sync iterator?

@bnoordhuis
Copy link
Contributor

bnoordhuis commented Oct 25, 2024

W.r.t. wrapping iterators: I imagine you add a new JS_CLASS_ITERATOR_HELPER and instantiate it with JS_NewObjectClass().

The class probably needs to be defined as such:

ctx->class[JS_CLASS_ITERATOR_HELPER] = JS_NewObjectProto(ctx, ctx->iterator_proto);

And have .next and .return methods that call the methods of the same name on the wrapped object (edit: and have mark and finalize callbacks.)

@saghul
Copy link
Contributor Author

saghul commented Oct 25, 2024

That's what I had in mind. Great, I'll try to give it a go this week!

@saghul saghul merged commit 82607f4 into master Oct 25, 2024
47 checks passed
@saghul saghul deleted the iterator-some branch October 25, 2024 20:37
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.

2 participants