@steeringwaves/sleep
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

@steeringwaves/sleep

workflow

A typescript async sleep utility.

Example

Promises

const Sleep = require("@steeringwaves/sleep").default;

Sleep(500).then(() => console.log("500ms sleep finished")); // sleep 500ms
await Sleep(1000); // sleep 1s
console.log("1s sleep finished");

Using contexts

const Context = require("@steeringwaves/context").default;
const Sleep = require("@steeringwaves/sleep").default;

const ctx = new Context();

Sleep(2000)
	.setContext(ctx)
	.onCancel(() => {
		console.log("sleep canceled");
	})
	.then(() => console.log("sleep completed"))
	.catch((e) => console.log(e));

ctx.Done();

/@steeringwaves/sleep/

    Package Sidebar

    Install

    npm i @steeringwaves/sleep

    Weekly Downloads

    0

    Version

    0.1.0

    License

    ISC

    Unpacked Size

    129 kB

    Total Files

    40

    Last publish

    Collaborators

    • lbainbridge
    • devmcclu
    • maxattax
    • 1800alex