Skip to content

Instantly share code, notes, and snippets.

View carlelieser's full-sized avatar
😼

Carlos Santos carlelieser

😼
View GitHub Profile
@carlelieser
carlelieser / asyncForEach.js
Created January 27, 2021 05:52
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);
};
@carlelieser
carlelieser / asyncForEach.ts
Created January 27, 2021 05:49
async forEach / typescript
Array.prototype.asyncForEach = async function asyncForEach(
fn: (item: any, index: number) => void,
index: number = 0
) {
await fn(this[index], index);
if (index + 1 === this.length) return;
await asyncForEach.call(this, fn, index + 1);
};
[
{
"title": "3D printing",
"category": "General",
"subCategory": "Indoors"
},
{
"title": "Acrobatics",
"category": "General",
"subCategory": "Indoors"