sleep

Returns a promise that resolves after a certain milliseconds.

Import

import { sleep } from '@fullstacksjs/toolbox';

Signature

function sleep(ms: number): Promise<void> {}

Examples

sleep(1000).then(() => console.log("Hi")) // Logs hi after 1 second
await sleep(1000); console.log("Hi")      // Logs hi after 1 second