Skip to content

Implement Iterator.prototype.some#627

Merged
saghul merged 1 commit intomasterfrom
iterator-some
Oct 25, 2024
Merged

Implement Iterator.prototype.some#627
saghul merged 1 commit intomasterfrom
iterator-some

Conversation

@saghul
Copy link
Copy Markdown
Contributor

@saghul saghul commented Oct 25, 2024

No description provided.

@saghul saghul requested a review from bnoordhuis October 25, 2024 07:21
@saghul
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
@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