implement Promise.all()
2022年5月1日小于 1 分钟
Promise.all()
implement Question
The Promise.all() method takes an iterable of promises as an input, and returns a single Promise that resolves to an array of the results of the input promises
source - MDN
Could you write your own all()
? which should works the same as Promise.all()
note
Do not use Promise.all() directly, it is not helping
Code
/**
* @param {Array<any>} promises - notice input might have non-Promises
* @return {Promise<any[]>}
*/
function all(promises) {
// your code here
}
Related
- implement async helper -
parallel()
- implement
Promise.allSettled()
- implement
Promise.any()
- implement
Promise.race()