From 1c0179152fae42da0515e3b05071b5fe5b61f4b4 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 19 Jun 2022 14:04:03 +0300 Subject: [PATCH] experimenting... Signed-off-by: Alex A. Naanou --- generator.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/generator.js b/generator.js index 1e7561d..bc1ccb8 100644 --- a/generator.js +++ b/generator.js @@ -455,6 +455,7 @@ object.Mixin('AsyncGeneratorProtoMixin', 'soft', { // -> promise // // NOTE: this will unwind the generator... + // XXX should we unwind??? then: function(resolve, reject){ var that = this var p = new Promise(async function(_resolve, _reject){ @@ -468,10 +469,17 @@ object.Mixin('AsyncGeneratorProtoMixin', 'soft', { && p.catch(reject) return p }, - // create an iterator promise... + // XXX create an iterator promise... iter: function(handler=undefined){ // XXX }, + // XXX not sure if this is the right way to go... + // XXX should we unwind??? + iter2: async function*(handler=undefined){ + for async(var e of this){ + yield* handler ? + handler.call(this, e) + : [e] } }, }) AsyncGeneratorMixin(AsyncGeneratorPrototype)