Skip to content

Conversation

bnoordhuis
Copy link
Contributor

No description provided.

method = JS_GetProperty(ctx, obj, JS_ATOM_next);
if (JS_IsException(method))
return JS_EXCEPTION;
// honestly kind of ghetto but avoids having to
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I understand what you are doing here. Care to satify my curiosity? :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The spec requires that you return a wrapped iterator and I accomplish that by basically doing:

var inner = /* ... */
var outer = { __proto__: Iterator.prototype, next: inner.next.bind(inner) }
return outer

The responsible-adult solution would probably involve an additional class with internal fields for inner and inner.next, custom mark and finalize functions, etc. This was less work :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it, thanks!

@bnoordhuis bnoordhuis merged commit 348d609 into quickjs-ng:master Sep 26, 2024
52 checks passed
@bnoordhuis bnoordhuis deleted the Iterator.from branch September 26, 2024 22:16
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