From 4be131e66b1fbdce51e8c52328fa7e97c593a03d Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 29 Dec 2022 15:57:56 +0300 Subject: [PATCH] notes... Signed-off-by: Alex A. Naanou --- Promise.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/Promise.js b/Promise.js index 90f65a7..1d8e7dc 100644 --- a/Promise.js +++ b/Promise.js @@ -344,6 +344,9 @@ object.Constructor('IterablePromise', Promise, { return list [map]( function(elem){ + // NOTE: we are calling .flat() on the result so we + // need to keep a handled array as a single + // element by wrapping the return of handled(..)... return elem instanceof IterablePromise ? // XXX should elem be expanded??? (like Array below) (elem.isSync() ? @@ -353,23 +356,23 @@ object.Constructor('IterablePromise', Promise, { // sync sync promise... : (elem instanceof SyncPromise && !(elem.sync() instanceof Promise)) ? - [handler(unwrap(elem.sync()))] + [handler(unwrap( elem.sync() ))] // promise / promise-like... : elem && elem.then ? // NOTE: when this is explicitly stopped we // do not call any more handlers after // STOP is thrown/returned... + // NOTE: the promise protects this from .flat() + // XXX do we need to wrap the handler(..) result + // in an array here??? -- TEST!!! // XXX TEST!!! elem.then(function(elem){ return !stop ? - handler(unwrap(elem)) + handler(unwrap( elem )) : [] }) : elem instanceof Array ? - // NOTE: we are calling .flat() on the result - // so we need to keep a handled array as - // a single element by wrapping the return - // of handled(..)... - [handler(unwrap(elem))] + [handler(unwrap( elem ))] + // raw element... : handler(elem) }, // handle STOP... function(){