promise.all polyfill
Promise.myAll = function (promises) {
var count = promises.length
var result = new Array(count).fill(false)
return new Promise((resolve, reject) => {
var checkIfDone = () => {
if (--count === 0) resolve(result)
}
promises.forEach((promise, index) => {
promise.then( (x) => {
result[index] = x
}, reject).then(checkIfDone)
})
})
}