Exciting release!Introducing "safe npm". Learn more
Socket
Log inDemoInstall

fun-dispatcher

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Issues
File Explorer

Advanced tools

fun-dispatcher

Tiny ES6 class to run functions after a given delay. Uses just on timer at any time and setImmediate to launch

    1.2.6latest
    GitHub

Version published
Maintainers
1
Weekly downloads
446
decreased by-44.04%

Weekly downloads

Readme

Source

codecov

fun-dispatcher

Tiny ES6 class to run functions after a given delay. Uses just one timer at any time and setImmediate to execute functions.

Written in Typescript, 100% test coverage, targeting current LTS Node.JS

Example:

const { Scheduler } = require('fun-dispatcher'); const fd = new Scheduler(); fd.schedule('task1', () => { console.log('Will run after about 600ms') }, 600); fd.schedule('task2', () => { console.log('Tasks can be cancelled by id'); fd.delete('task1') }, 400) // can forcefully execute all tasks fd.flush(); // or just next task in line waiting for be executed fd.runNext() // Scheduler extends native Map class, so, all methods are available // like .delete to unschedule task or iteration for (const [task, { delay }] of fd) { console.log('Task `%s` was scheduled with original delay of %d ms', task, delay); }

Keywords

FAQs

Last updated on 08 Dec 2020

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket
support@socket.devSocket SOC 2 Logo

Product

  • Package Issues
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc