Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

extra-timers

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extra-timers

Utilities for timers

  • 0.2.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

extra-timers

Utilities for timers.

Install

npm install --save extra-timers
# or
yarn add extra-timers

API

setTimeout

function setTimeout(timeout: number, cb: () => unknown): () => void

A wrapper for globalThis.setTimeout, with the following differences:

  • Better order of parameters.
  • No function parameters binding.
  • The return value is the function to cancel the timer.

setSchedule

function setSchedule(timestamp: number, cb: () => unknown): () => void

setInterval

function setInterval(timeout: number, cb: () => unknown): () => void

A wrapper for globalThis.setInterval, with the following differences:

  • Better order of parameters.
  • No function parameters binding.
  • The return value is the function to cancel the timer.

setImmediate

function setImmediate(cb: () => unknown): () => void

A wrapper for globalThis.setImmedidate, with the following differences:

  • No function parameters binding.
  • The return value is the function to cancel the timer.

When globalThis.setImmediate does not exist, it will fall back to setTimeout(cb, 0).

setTimeoutLoop

function setTimeoutLoop(timeout: number, cb: () => unknown): () => void

Create an interval timer using the nested setTimeout, which does not schedule the next run until the callback function returns.

The return value is the function to cancel the timer.

setDynamicTimeoutLoop

function setDynamicTimeoutLoop(timeout: number, cb: () => unknown): () => void

Create an interval timer using the nested setTimeout, which does not schedule the next run until the callback function returns, and dynamically adjusts the interval time based on the execution time of the callback function.

The return value is the function to cancel the timer.

calculateExponentialBackoffTimeout

function calculateExponentialBackoffTimeout({
  baseTimeout
, retries
, maxTimeout = Infinity
, factor = 2
, jitter = true
}: {
  baseTimeout: number
  retries: number
  maxTimeout?: number
  factor?: number
  jitter?: boolean
}): number

Keywords

FAQs

Package last updated on 11 Jun 2023

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