Closed dead-claudia closed 9 months ago
Since iterators clearly are intended to use the disposer pattern, shouldn't sync iterators (like generators) also implement @@dispose/@@asyncDispose?
@@dispose
@@asyncDispose
The implementations would just trivially delegate to return if present:
return
IteratorPrototype[Symbol.dispose] = function () { const f = this.return if (f != null) const {} = f.call(this) } AsyncIteratorPrototype[Symbol.dispose] = function () { const f = this.return if (f != null) const {} = await f.call(this) }
I appreciate the feedback, but this is already included within the specification:
Ah, whoops. Completely missed that!
Since iterators clearly are intended to use the disposer pattern, shouldn't sync iterators (like generators) also implement
@@dispose
/@@asyncDispose
?The implementations would just trivially delegate to
return
if present: