mirror of
https://github.com/flynx/types.js.git
synced 2025-10-28 18:10:08 +00:00
added for-await-of support for Promise.iter(..)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
6f826bc9c0
commit
993faa672d
@ -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...
|
||||
//
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user