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

timer-wheel

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

timer-wheel

Timer wheel for implementing things such as expirations

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
220
decreased by-3.93%
Maintainers
1
Weekly downloads
 
Created
Source

Timer Wheel

npm version Build Status Coverage Status Dependencies

timer-wheel is a JavaScript library for efficiently managing a large amount of timed actions. It allows you to schedule actions after a certain delay and then control when to advance and run actions where the delay has passed.

This implementation is designed for larger delays and has a minimum delay of 1000 ms.

import { TimerWheel } from 'timer-wheel';

const wheel = new TimerWheel();
wheel.schedule(() => {
  console.log('Action invoked');
}, 1500 /* ms */)

// Call `advance()` to advance the wheel and run actions
setInterval(() => {
  wheel.advance();
}, 1000);

This library is useful for things like expiring caches with lazy expiration, instead of checking if every cache item should be expired use a wheel to queue removal actions and call advance before every get/set. This is how Transitory implements expiring caches.

Keywords

FAQs

Package last updated on 22 Jul 2019

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