1.1.0 • Published 5 years ago
@aymandev/pausabletimers v1.1.0
PausableTimers
Getting Started
Installation
npm install @aymandev/pausabletimers
How to use this timers?
Almost same as default setTimeout
and setInterval
.
First need to declare timer variable:
const timer = setPausableTimeout(() => console.log("message"), 5000);
This timeout will execute after 5 seconds.
How to use interval timer?
Just have to change function name little bit:
const timer = setPausableInterval(() => console.log("message"), 5000);
How to pause timer?
Just have to call method from timer:
timer.pauseTimer();
Also you can pause timer for N milliseconds:
timer.pauseTimer(3000); // Timer will unpause after 3 seconds
How to unpause timer?
Just have to call method from timer:
timer.startTimer();