Skip to content

Instantly share code, notes, and snippets.

@carlelieser
Created January 27, 2021 05:52
Show Gist options
  • Save carlelieser/3b7f8192b6030ff083bd6838af67af60 to your computer and use it in GitHub Desktop.
Save carlelieser/3b7f8192b6030ff083bd6838af67af60 to your computer and use it in GitHub Desktop.
async forEach / javascript
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