Skip to content

Delay a promise a specified amount of time with the ability to clear the delay.

License

Notifications You must be signed in to change notification settings

bsnote/node-clearable-delay

Repository files navigation

clearable-delay

Delay a promise a specified amount of time with the ability to clear the delay.

Usage

import { clearableDelay } from "clearable-delay";

(async () => {
  const delayedPromise = clearableDelay(1000);

  setTimeout(() => delayedPromise.clear(), 500);

  const cleared = await delayedPromise;

  console.log(cleared ?
    "Cleared before timing out" :
    "Timed out after 1000ms");
})()

License

MIT © Andrei Sedoi

About

Delay a promise a specified amount of time with the ability to clear the delay.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published