You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 1-js/12-generators-iterators/2-async-iterators-generators/article.md
+5-7Lines changed: 5 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -345,20 +345,18 @@ When we expect the data to come asynchronously, with delays, their async counter
345
345
346
346
Syntax differences between async and regular iterators:
347
347
348
-
| | Iterators | Async iterators |
348
+
| | Iterable | Async Iterable |
349
349
|-------|-----------|-----------------|
350
-
| Object method to provide iterator | `Symbol.iterator` | `Symbol.asyncIterator` |
351
-
| `next()` return value is | any value | `Promise` |
350
+
| Method to provide iterator | `Symbol.iterator` | `Symbol.asyncIterator` |
351
+
| `next()` return value is | `{value:…, done: true/false}` | `Promise` that resolves to `{value:…, done: true/false}` |
352
352
353
353
Syntax differences between async and regular generators:
354
354
355
355
| | Generators | Async generators |
356
356
|-------|-----------|-----------------|
357
357
| Declaration | `function*` | `async function*` |
358
-
| `generator.next()` returns | `{value:…, done: true/false}` | `Promise` that resolves to `{value:…, done: true/false}` |
358
+
| `next()` return value is | `{value:…, done: true/false}` | `Promise` that resolves to `{value:…, done: true/false}` |
359
359
360
360
In web-development we often meet streams of data, when it flows chunk-by-chunk. For instance, downloading or uploading a big file.
361
361
362
-
We can use async generators to process such data, but it's also worth to mention that there's also another API called Streams, that provides special interfaces to work with such streams, to transform the data and to pass it from one stream to another (e.g. download from one place and immediately send elsewhere).
363
-
364
-
Streams API is not a part of JavaScript language standard.
362
+
We can use async generators to process such data. It's also noteworthy that in some environments, such as browsers, there's also another API called Streams, that provides special interfaces to work with such streams, to transform the data and to pass it from one stream to another (e.g. download from one place and immediately send elsewhere).
0 commit comments