Created
January 27, 2021 05:52
-
-
Save carlelieser/3b7f8192b6030ff083bd6838af67af60 to your computer and use it in GitHub Desktop.
async forEach / javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.asyncForEach = async function asyncForEach(fn, index = 0) { | |
await fn(this[index], index); | |
if (index + 1 === this.length) return; | |
await asyncForEach.call(this, fn, index + 1); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment