Skip to content

Files

Latest commit

Apr 18, 2020
4d063c0 · Apr 18, 2020

History

History

delay_until

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
Apr 18, 2020
Oct 31, 2019
Jun 20, 2019
Apr 18, 2020

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/deno_mod@v0.10.0/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