๐๐ป CaL mE YaThi
๐ BeLIeVe In Me
๐ฝ๏ธ HotELieR
๐ LOgiN To EArTh On 14 Aug
๐ INoCenT
๐ค SoFtWare EnGinEer
๐ เคฆเฅเคถเคฎเฅเคเฅ In Blood
๐ค WoRkiNg @Recro
๐๐ป CaL mE YaThi
๐ BeLIeVe In Me
๐ฝ๏ธ HotELieR
๐ LOgiN To EArTh On 14 Aug
๐ INoCenT
๐ค SoFtWare EnGinEer
๐ เคฆเฅเคถเคฎเฅเคเฅ In Blood
๐ค WoRkiNg @Recro
i think best way to achieve this making prototype function and then good to go
Array.prototype.forAsyncSerial = async function (fn = null) {
let result = [];
for (let i = 0; i < this.length; i++) {
if (typeof fn !== 'function') result[i] = await this[i];
else result[i] = await fn(this[i], i);
}
return result;
};
Array.prototype.forAsyncParallel = async function (fn = null) {
if (typeof fn !== 'function') return await Promise.all(this);
else return await Promise.all(this.map(fn));
};
Good suggestion. Mind if I use this in the next video :)
Dont forget to mention my name ๐
absolutely ๐๐