From c1f7ba1b031909bd9d740fd467734e06b985d81a Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 16 Jun 2022 00:32:58 +0300 Subject: [PATCH] bugfix... Signed-off-by: Alex A. Naanou --- Promise.js | 33 +++++++++++++++++---------------- package.json | 2 +- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Promise.js b/Promise.js index 2001975..c14898c 100644 --- a/Promise.js +++ b/Promise.js @@ -198,6 +198,20 @@ object.Constructor('IterablePromise', Promise, { : handler(elem) }) }, //*/ // transform/handle packed array (sync)... + // + // XXX BUG: + // await Promise.iter(['a', Promise.resolve(222), ['c']]) + // .map(async e => e) + // -> ['a', , ['c']] + // is not the same as: + // await Promise.iter(['a', Promise.resolve(222), ['c']]) + // .map(e => e) + // -> ['a', 222, ['c']] + // ...and these works as expected: + // await Promise.iter(['a', Promise.resolve(222), ['c']], async e => [e]) + // -> ['a', 222, ['c']] + // await Promise.iter(['a', Promise.resolve(222), ['c']], e => [e]) + // -> ['a', 222, ['c']] __handle: function(list, handler=undefined){ var that = this if(typeof(list) == 'function'){ @@ -225,8 +239,9 @@ object.Constructor('IterablePromise', Promise, { that.__pack(elem, handler) : elem instanceof Promise ? that.__pack(elem, handler) - .then(function(elem){ - return elem.flat() }) + //.then(function(elem){ + .then(function([elem]){ + return elem }) : [handler(elem)] }) .flat() }, // unpack array (async)... @@ -523,20 +538,6 @@ object.Constructor('IterablePromise', Promise, { // NOTE: if 'types/Array' is imported this will support throwing STOP, // for more info see notes for .__pack(..) // XXX EXPEREMENTAL: STOP... - // - // XXX BUG: - // await Promise.iter(['a', Promise.resolve(222), ['c']]) - // .map(async e => e) - // -> ['a', , ['c']] - // is not the same as: - // await Promise.iter(['a', Promise.resolve(222), ['c']]) - // .map(e => e) - // -> ['a', 222, ['c']] - // ...and these works as expected: - // await Promise.iter(['a', Promise.resolve(222), ['c']], async e => [e]) - // -> ['a', 222, ['c']] - // await Promise.iter(['a', Promise.resolve(222), ['c']], e => [e]) - // -> ['a', 222, ['c']] __new__: function(_, list, handler){ // instance... var promise diff --git a/package.json b/package.json index fdde40a..eddb9af 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ig-types", - "version": "6.15.0", + "version": "6.15.1", "description": "Generic JavaScript types and type extensions...", "main": "main.js", "scripts": {