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

timer-jobs

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timer-jobs

Create timers that can run often, but not block by long executions

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
45
increased by18.42%
Maintainers
1
Weekly downloads
 
Created
Source

timer-jobs

Create timers that can run often, but not block by long executions. Great for worker-roles and such that have many jobs to do periodically.

Installation

	$ npm install timer-jobs

Usage

var TimerJob = require('timer-jobs');

var someTimer = new TimerJob({interval: 5000}, function(done) {
	console.log('hey');
	done();
});
someTimer.start();

TimerJob Class

constructor (options, callback)

Options:

  • blocking: boolean - This determines if the timer should allow a new callback to be started before one finishes. Defaults to true.
  • interval: Interval time, in milliseconds. Attempts to start the callback at this value.
  • autoStart: boolean - No need to call timer.start() after creating the timer. Defaults to false.
  • immediate: boolean - If true, calls the callback right when the job starts, doesn't wait for interval milliseconds. Defaults to false
  • ignoreErrors: boolean - Ff true, automatically restarts the job if an error was sent from the callback.

Callback:

The function to call every interval milliseconds.

timer.start()

Starts up ye olde job!

timer.stop()

Stop the job! If a callback is in the middle of execution, it does not cancel it. Only when it calls back.

Event: start

function() {}

Emitted when the timer has successfully started.

Event: stop

function() {}

Emitted when the timer has successfully stopped.

Event: jobStart

function() {}

Emitted on every interval, BEFORE the callback function is called

Event: jobStop

function([err], [args]) {}

Emitted every time the callback calls its done function. If there is an error - the job HALTS until you start it back up, or if options.ignoreErrors is true.

  • err: Error passed from the callback
  • args: Any additional arguments passed from the callback

Keywords

FAQs

Package last updated on 14 Dec 2013

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