@@ -399,9 +399,12 @@ Array.fromAsync([], 1);
399
399
### Closing sync iterables?
400
400
Array.fromAsync tries to match ` for await ` ’s behavior as much as possible.
401
401
402
- This includes how ` for await ` currently does not close sync iterables when it
402
+ Previously, ` for await ` did not close sync iterables when it
403
403
yields a rejected promise.
404
404
405
+ <details>
406
+ <summary>Old code example</summary>
407
+
405
408
` ` ` js
406
409
function * createIter () {
407
410
try {
@@ -433,13 +436,19 @@ for await (const x of createIter()) {
433
436
Array .fromAsync (createIter ());
434
437
` ` `
435
438
436
- TC39 has agreed to change ` for await ` ’s behavior here. In the future, ` for await ` will
437
- close sync iterators when async wrappers yield rejections (see [tc39/ecma262#2600][]).
438
- When that behavior changes for ` for await ` , then it will also change for ` Array .fromAsync `
439
- at the same time.
439
+ </details>
440
+
441
+ TC39 has recently changed ` for await ` ’s behavior here.
442
+ In the latest version of the language,
443
+ ` for await ` now will close sync iterators when async wrappers yield rejections (see [tc39/ecma262#2600][]).
444
+ All of the JavaScript engines are already updating to this new behavior.
440
445
441
446
[tc39/ecma262#2600]: https://github.com/tc39/ecma262/pull/2600
442
447
448
+ ` Array .fromAsync ` matches this new behavior of ` for await ` .
449
+ Both will close any given sync iterator
450
+ when the sync iterator yields a rejected promise as its next value.
451
+
443
452
## Other proposals
444
453
445
454
### Relationship with iterator-helpers
0 commit comments