Simple function to wait a period of time before proceeding.
In JavaScript:
const sleep = ms => new Promise(r => setTimeout(r, ms));
In TypeScript:
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
Usage:
await sleep(1000);
Simple function to wait a period of time before proceeding.
In JavaScript:
const sleep = ms => new Promise(r => setTimeout(r, ms));
In TypeScript:
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
Usage:
await sleep(1000);