This module exports a retimeableSignal function that returns an AbortSignal that fires an "abort" event after a specified number of ms.
retimeableSignal
AbortSignal
It has been augmented with two additional methods reset and clear which change the timeout time and prevent it from firing entirely.
reset
clear
import { retimeableSignal } from 'retimeable-signal'const signal = retimeableSignal(100)//... time passes, reset timeout to now + 100mssignal.reset(100)// stop the signal from aborting at allsignal.clear() Copy
import { retimeableSignal } from 'retimeable-signal'const signal = retimeableSignal(100)//... time passes, reset timeout to now + 100mssignal.reset(100)// stop the signal from aborting at allsignal.clear()
This is module is inspired by the retimer module except that uses setTimeout which can cause a Node.js process to stay open, this uses AbortSignal.timeout which does not.
setTimeout
AbortSignal.timeout
This module exports a
retimeableSignal
function that returns anAbortSignal
that fires an "abort" event after a specified number of ms.It has been augmented with two additional methods
reset
andclear
which change the timeout time and prevent it from firing entirely.Example
Prior art
This is module is inspired by the retimer module except that uses
setTimeout
which can cause a Node.js process to stay open, this usesAbortSignal.timeout
which does not.