Skip to content

Latest commit

 

History

History
65 lines (42 loc) · 2.34 KB

README.md

File metadata and controls

65 lines (42 loc) · 2.34 KB

delay_until

A typical delay function but Promise based


MIT License

Unlike thread sleep, this is achieved by wrapping a setTimeout inside Promise. It's best to use with async...await syntax.

Table of contents

Usage

/** Import from GH via `denopkg` */
import { delayUntil } from "https://cdn.jsdelivr.net/gh/motss/[email protected]/delay_until/mod.ts";

(async () => {
  await delayUntil(3e3);

  console.log("This message prints out after 3 seconds");
})();

API Reference

delayUntil([delay])

  • delay <?number> The delay, in milliseconds, the function should wait for before any code after where the delay function is called can be executed. This does not affect code execution in other thread, module, or even file.
  • returns: <Promise<undefined>> Promise which resolves with no return value.

License

MIT License © Rong Sen Ng