Skip to content

Instantly share code, notes, and snippets.

@tristancamejo
Created July 13, 2022 11:41
Show Gist options
  • Save tristancamejo/c113f9b5738028ec1c5d6a846003e9a0 to your computer and use it in GitHub Desktop.
Save tristancamejo/c113f9b5738028ec1c5d6a846003e9a0 to your computer and use it in GitHub Desktop.
const testArray: number[] = [];
for (let i = 0; i < 100; i++) {
testArray.push(i);
}
for (const { index, element } of testArray.map((element, index) => ({
index,
element,
}))) {
if (index % 5 === 0 && index !== 0) {
console.log(`Taking a break... ${index.toString()}/
${testArray.length.toString()},
)}`);
await new Promise((resolve) => setTimeout(resolve, 5000));
}
console.log(`up to ${index}`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment