You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@exodus/timer

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@exodus/timer

Timer that allows you to schedule tasks at fixed intervals

1.2.2
latest
Source
npmnpm
Version published
Weekly downloads
5.7K
27.45%
Maintainers
1
Weekly downloads
 
Created
Source

@exodus/timer

Timer helper class

Install

    yarn add @exodus/timer

Usage

Timer that allows scheduling tasks at fixed intervals (ticks). It keeps track of the running timers statically. You can start, pause, stop or clear all the tasks.

Starting the timer with start() will execute the first tick unless the delayedStart option is supplied. When started without a delayStart, start() may throw an exception if tick() throws. To prevent start() from failing, make sure you handle the errors appropriately.

Start timer async

With async start, make sure you catch any unhandled errors.

const timer = new Timer(100)
timer.start(() => this.hello(options)).catch((err) => {})
await timer.stop()

Start timer sync

If you need to wait for the first tick to complete, start the timer like this:

const timer = new Timer(100)
try {
  await timer.start(() => this.hello(options))
} catch (err) {}
await timer.stop()

Note that awaiting for start also waits for the first tick to complete. This may delay the startup operation especially with long-running ticks.

FAQs

Package last updated on 19 May 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts