ysmood / yaku

A lightweight promise library
https://tonicdev.com/ysmood/yaku
MIT License
291 stars 28 forks source link

Promise.all and Promise.allSettled doesn't work if the promise array has been created in a different frame. #72

Open rdeangelis83 opened 3 years ago

rdeangelis83 commented 3 years ago

Method isInstanceOf (used in each method) doesn't work correctly for arrays created in a different frame. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray

Array.isArray is the better alternative but is not implemented in all browser so I would suggest following:

        function isArray(obj) {
            if (Array.isArray && Array.isArray(obj)) {
                return true;
            }

            if (isInstanceOf(obj, Arr)) {
                return true;
            }

            if (Object.prototype.toString.call(obj) === "[object Array]") {
                return true;
            }

            return false;
        }
}
ysmood commented 3 years ago

Could you help to make a PR for it?

rdeangelis83 commented 3 years ago

Of course. I will make a PR this evening.