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

timers-ext

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timers-ext

Timers extensions

  • 0.1.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.5M
increased by5.6%
Maintainers
1
Weekly downloads
 
Created

What is timers-ext?

The timers-ext npm package provides extended timer functionalities for JavaScript, including delay, debounce, throttle, and more. It is useful for managing and controlling the execution of functions over time.

What are timers-ext's main functionalities?

delay

The delay function pauses the execution of the code for a specified amount of time. In this example, the code waits for 2 seconds before logging 'End'.

const delay = require('timers-ext/delay');

async function example() {
  console.log('Start');
  await delay(2000); // Delay for 2 seconds
  console.log('End');
}

example();

debounce

The debounce function ensures that a function is only called once after a specified delay period has passed since the last time it was invoked. This is useful for events like window resizing.

const debounce = require('timers-ext/debounce');

function onResize() {
  console.log('Resized');
}

const debouncedResize = debounce(onResize, 300);

window.addEventListener('resize', debouncedResize);

throttle

The throttle function ensures that a function is called at most once in a specified time period. This is useful for events like scrolling where you want to limit the number of times a function is called.

const throttle = require('timers-ext/throttle');

function onScroll() {
  console.log('Scrolled');
}

const throttledScroll = throttle(onScroll, 1000);

window.addEventListener('scroll', throttledScroll);

Other packages similar to timers-ext

Keywords

FAQs

Package last updated on 03 Jun 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