set-time-can

1.0.0 • Public • Published

set-time-can

setTimeout promise & setInterval async-iterable that are cancelable

// our hero of the story
const controller= new AbortController()

console.log("please disarm within four seconds or face termination")
// if this timeout gets to zero...
setTimeout(4000, { signal: controller.signal})
  // bad things happen!
  .then(()=> (console.error("exploding"), process.exit(1)), ()=> console.log("disarmed"))
// the controllers `signal` raises an `abort` that setTimeout uses to shutdown early. whew!
setTimeout(2000).then(()=> controller.abort())

/set-time-can/

    Package Sidebar

    Install

    npm i set-time-can

    Weekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    4.66 kB

    Total Files

    7

    Last publish

    Collaborators

    • rektide