- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 19
 
Open
Labels
Description
Async-generators are stage3, so fairly likely to land in JS. Seems like fasy should support them eventually, probably sooner than later.
[UPDATE]: They landed in ES2018.
For example:
FP.serial.map(async function *mapper(v){
    if (await lookup(v)) v = yield something(v);
    return v;
});Implementation should be fairly straightforward, in _runner(..).
Note: I don't think the for-await-of loop will work to run the async-generator, because that construct doesn't let us send a "next value" back in after each iteration. But I think we can do a for-of loop with await inside it, to get almost the same syntax-sugar but have the capability to drive the iterator as we need to. We'll look for Symbol.asyncIterator to know that we need to take this path.
However, before proceeding, we need to decide:
-  if the async-generator 
yields out a promise, do we wait on it and resume with its resolution, like we do in the normal generator-runner pattern? -  if the async-generator has a final return value, is that indeed the overall completion value of that function's promise (in 
_runner(..))? Usually,returnd values from a generator would be thrown away -  if the async-generator does not have a return value (or if it's 
returnorreturn undefined), should we assume the lastyielded value (or its resolution, if it was a promise) as the overall completion of that function's promise (in_runner(..))?