Socket
Socket
Sign inDemoInstall

clockworker

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clockworker

Spawn workers that can loop tasks, and subscribe to events


Version published
Weekly downloads
7
decreased by-22.22%
Maintainers
1
Weekly downloads
 
Created
Source

🕰️ Clockworker

code style: prettier

A lightweight library to spawn workers that can loop tasks, and subscribe to events.

Installation

npm i clockworker

Usage

const { Clockworker, EventsBroker } = require('clockworker');

// Instance a worker that sends an event every 6 seconds
const myEventEmitter = new Clockworker();
myEventEmitter.loop(6000, () => EventsBroker.emit('myEvent', 'Eat'));

// Instance worker
const myWorker = new Clockworker();

// ... which listen to events ...
myWorker.listen('myEvent', (data) => console.log(data));

// ... and loops tasks.
const build = () => console.log('Build');
const coffee = () => console.log('Drink Coffe');
myWorker.loop(2000, () => build()); //Loop every 2 seconds
myWorker.loop(4000, () => coffee()); //Loop every 4 seconds

License

MIT

Keywords

FAQs

Package last updated on 06 Mar 2022

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