Asynchronous iteration (for-await-of) and ForOfStatement deprecation
See original GitHub issue'use strict';
(async () => {
for await (const item of [Promise.resolve('a'), Promise.resolve('b')]) {
console.log(item);
}
})();
4:3 error iterators/generators require regenerator-runtime, which is too heavyweight for this guide to allow them. Separately, loops should be avoided in favor of array iterations no-restricted-syntax
Should the ForOfStatement
entry in no-restricted-syntax
be alleviated in such cases? Maybe it is worth to remove the second part of the message (“loops should be avoided in favor of array iterations”), since there seems to be no easy different way for array asynchronous iteration?
Is there a way for AST parser to distinguish an async ForOfStatement
from a sync one?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:8 (1 by maintainers)
Top Results From Across the Web
for await...of - JavaScript - MDN Web Docs
The for await...of statement creates a loop iterating over async iterable objects as well as sync iterables. This statement can only be used ......
Read more >Async iteration and generators - The Modern JavaScript Tutorial
Asynchronous iteration allow us to iterate over data that comes asynchronously, ... That's why async generators work with for await...of .
Read more >Documentation - TypeScript 2.3
This kind of iterator is useful for iterating over synchronously available values, such as the elements of an Array or the keys of...
Read more >for await...of - JavaScript - UDN Web Docs: MDN Backup
The for await...of statement creates a loop iterating over async iterable objects as well as on sync iterables, including: built-in String , Array...
Read more >Asynchronous Iterators in JavaScript | Codementor
A for..of statement creates a loop capable of iterating over iterable objects. The statement starts by invoking the custom [Symbol.iterator]() ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@vsemozhetbyt if you’re in a node-only environment, you can certainly override rules that are concerned with transpilation overhead.
For learning how the language works, a style guide isn’t going to be super helpful. Use every part of the language to learn! A style guide helps you mitigate and avoid and minimize the bad parts, once you already know how they work.