node-apex icon indicating copy to clipboard operation
node-apex copied to clipboard

Support array of promises

Open ajcrites opened this issue 9 years ago • 2 comments

If the lambda function returns an array, this module doesn't treat it as a promise and will just do cb on the pending promises. I suggest:

if (Array.isArray(v)) {
    Promise.all(v).then(function (val) /* etc. */
}

We can also just wrap v in Promise.all regardless since it will work even for non-arrays. It would be slightly less efficient to do this. There is also no guarantee that there is a promise in the array.

ajcrites avatar Aug 02 '16 19:08 ajcrites

you can just return Promise.all([ yourArray ]) yourself, would that work?

juliangruber avatar Jul 09 '17 06:07 juliangruber

@juliangruber yes, I'm suggesting this as an enhancement

ajcrites avatar Jul 09 '17 11:07 ajcrites