When awaited, delays the execution by the given number of milliseconds.

Type signature

(duration: number) => Promise<unknown>

Examples

delay(2000)(() =>
  console.log("Test")
);
Try in REPL

Questions

  • How to delay a function?
  • What is the JavaScript version of sleep()?

TypeScript sourceJavaScript source