- From: Luca Casonato <notifications@github.com>
- Date: Thu, 18 Jul 2024 02:05:54 -0700
- To: whatwg/webidl <webidl@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/webidl/pull/1397/review/2185183193@github.com>
@lucacasonato commented on this pull request. > +<div id="async-iterable-to-js" algorithm="convert an async iterable to a JavaScript value"> + An IDL <a lt="async iterable type">async iterable<|<var ignore>T</var>></a> value is + [=converted to a JavaScript value|converted=] to a JavaScript object as follows: + + 1. Return the JavaScript object that represents the same async iterable as the IDL value. +</div> > Would it be an option for us to just disallow converting an IDL async iterable type back to a JavaScript value? That was indeed my intention, except for the case where the value just has to pass through IDL momentarially (like in functions like `setTimeout`, that call a passed callback with passed arguments). I am not sure now whether this is needed, but earlier reading of the spec made me beleive that all IDL values had to have a way to convert back to JS for these cases - maybe I am wrong. > I think we should make "convert from a JavaScript object" not call GetIterator(): That seems reasonable. I think the converter should do the following: 1. Check `Type(V)` is `Object` 2. Check that `V` has a `Symbol.asyncIterator` or `Symbol.iterator` property, and if so, store it. (But do not call it yet.) Then the `open an async iterable` algorithm: 1. Calls the iterator method stored during the conversion (using [ECMA262's `GetIteratorFromMethod`](https://tc39.es/ecma262/#sec-getiteratorfrommethod)) 2. Returns the ECMA262's `Iterator` record (or an IDL wrapper thereof) The other async iterable algorithms are then modified to work with it. -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/webidl/pull/1397#discussion_r1682486918 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/webidl/pull/1397/review/2185183193@github.com>
Received on Thursday, 18 July 2024 09:05:58 UTC