New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@exodus/timer

Package Overview
Dependencies
Maintainers
0
Versions
6
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.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.1K
decreased by-4.44%
Maintainers
0
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 01 Nov 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc