П
const parallel = (funcArray, doneAll) =>
Promise.all(funcArray.map(f => new Promise(r => f(r)))).then(doneAll)
Size: a a a
DE
const parallel = (funcArray, doneAll) =>
Promise.all(funcArray.map(f => new Promise(r => f(r)))).then(doneAll)
t
const parallel = async (funcArray) => new Promise((resolve, reject) => {
const resultArray = []
let summary = 0
funcArray.map((p, i) => Promise.resolve(p).then((value, error) => {
if ( error )
reject(error)
resultArray[i] = value
if ( ++summary === funcArray.length )
resolve(resultArray)
}))
})
П
const parallel = (funcArray, doneAll) =>
Promise.all(funcArray.map(f => new Promise(r => f(r)))).then(doneAll)
DE
t
L
П
p.then(resolve)
П
L
L
const myPromiseAll = async (funcArray) => new Promise((resolve, reject) => {
const resultArray = []
let summary = 0
funcArray.map((p, i) => Promise.resolve(p).then((value, error) => {
if ( error )
reject(error)
resultArray[i] = value
if ( ++summary === funcArray.length )
resolve(resultArray)
}))
})
const parallel = (funcArray, doneAll) =>
myPromiseAll(funcArray.map(f => new Promise(r => f(r)))).then(doneAll)
S
const myPromiseAll = async (funcArray) => new Promise((resolve, reject) => {
const resultArray = []
let summary = 0
funcArray.map((p, i) => Promise.resolve(p).then((value, error) => {
if ( error )
reject(error)
resultArray[i] = value
if ( ++summary === funcArray.length )
resolve(resultArray)
}))
})
const parallel = (funcArray, doneAll) =>
myPromiseAll(funcArray.map(f => new Promise(r => f(r)))).then(doneAll)
П
const myPromiseAll = async (funcArray) => new Promise((resolve, reject) => {
const resultArray = []
let summary = 0
funcArray.map((p, i) => Promise.resolve(p).then((value, error) => {
if ( error )
reject(error)
resultArray[i] = value
if ( ++summary === funcArray.length )
resolve(resultArray)
}))
})
const parallel = (funcArray, doneAll) =>
myPromiseAll(funcArray.map(f => new Promise(r => f(r)))).then(doneAll)
DE
П
const resultArr = funcArray.map(funcTemp => {
const p = new Promise((resolve, reject) => {
funcTemp(strResult => {
resolve(strResult);
}).then(resolve => resolve);
});
return p.then(resolve );
});