added for-await-of support for Promise.iter(..)...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2022-08-19 18:02:40 +03:00
parent 6f826bc9c0
commit 993faa672d
3 changed files with 18 additions and 1 deletions

View File

@ -249,6 +249,15 @@ object.Constructor('IterablePromise', Promise, {
: (await Promise.all(list))
.flat() },
[Symbol.asyncIterator]: async function*(){
var list = this.__packed
if(list instanceof Promise){
yield this.__unpack(await list)
return }
for await(var elem of list){
yield* elem instanceof Array ?
elem
: [elem] } },
// iterator methods...
//

View File

@ -1580,6 +1580,14 @@ in how they process values:
appropriate method on the result.
<!-- XXX list + mark definitions as "(proxy)" -->
Promise iterators directly support _for-await-of_ iteration:
```javascript
for await (var elem of Promise.iter(/* ... */)){
// ...
}
```
<!--
XXX should we support generators as input?
...not sure about the control flow direction here, on one hand the generator

View File

@ -1,6 +1,6 @@
{
"name": "ig-types",
"version": "6.17.0",
"version": "6.18.0",
"description": "Generic JavaScript types and type extensions...",
"main": "main.js",
"scripts": {