@aymandev/pausabletimers
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

PausableTimers

Build Status Repo Size License npm

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();

Package Sidebar

Install

npm i @aymandev/pausabletimers

Weekly Downloads

11

Version

1.1.0

License

Apache-2.0

Unpacked Size

17.9 kB

Total Files

9

Last publish

Collaborators

  • aymandev