Wait

Sometimes when you are testing, or playing around, you just want to simulate some delay. Here's a simple way to do just that.

Date: 2022-12-31

timeout.ts
export function timeout(delay: number) {
    return new Promise( res => setTimeout(res, delay) );
}

Context

Sometimes when you are building something you want to see how it works with a little delay. I use this for playing with, or testing, React suspense.

Usage

waitExample.ts
import { timeout } from "../lib/timeout";

await timeout(1000); //for 1 sec delay

Edit this page