-
Notifications
You must be signed in to change notification settings - Fork 34
Do we want to expose AsyncFromSyncIterator? #172
Comments
We definitely should not make it possible to break the built-in |
It seems like it should be trivial enough to make |
Thanks for raising this. If the intent is to expose @ljharb, the problem is that the spec is written to handle an iterator record, regardless of what the iterator is, and lookup methods on it. While you may be able to update I'd personally prefer we find a way not to expose this previously spec internal object. |
I don’t see how exposing it is avoidable. |
i think the point here is more that for-await should be hardened than that we should try to hide AsyncFromSyncIterator. since AsyncFromSyncIterator doesn't technically exist yet we have a bit of creative freedom in how we specify AsyncIterator.from and for-await to handle these cases how we like. |
Since |
Currently
AsyncFromSyncIterator
exists pretty much entirely as spec fiction to enable sync iterators to be consumed by for-await-of and the like. However in the current spec text for the proposal the (probably intended) ofAsyncIterator.from
can return realAsyncFromSyncIterator
objects (and henceAsyncFromSyncIteratorPrototype
could be manipulated).Is this something we actually want to do however? At current by being just spec fiction, engines can presumably skip creation of such things entirely and go down short paths, however because of the way the iterator protocol works if
AsyncFromSyncIterator
objects are exposed, and consequently tampered with by manipulating their methods, such assumptions may be consequently broken.The simple way to avoid exposing them is just to wrap the
AsyncFromSyncIterator
itself again inAsyncIterator.from
, although I'm unsure if this double wrapping itself could expose things.If on the other hand we do want to expose
AsyncFromSyncIterator
for realsies do we actually want them returned fromAsyncIterator.from
? Currently no ECMA262 objects return concrete subclasses for these sort've methods*, although web APIs and various userland APIs do so it's not really unprecendented.* NOTE that
TypedArray
methods are accessed by their subclasses, in factTypedArray
isn't even exposed as a named global and requires looking up the prototype chain to even find.The text was updated successfully, but these errors were encountered: