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

rtimer

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rtimer

Persistent timer with set and clear

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
112
increased by17.89%
Maintainers
1
Weekly downloads
 
Created
Source

rtimer

Persistent timer with set and clear

Install

npm install rtimer

Usage

rtimer has two instance methods set and clear.

  • set restart the timeout
  • clear clear the current timeout, timeout can be restarted again after clear
  • callback property contains the callback method
  • delay property contains the timeout delay

Example

var rtimer = require('rtimer');

var start_time = +new Date();

// create new timeout with 1000ms delay
var timeout = rtimer(function() {
	// this will be triggered after 1500ms
	// because of the reset
	var t = (+new Date() - start_time);
	console.log('time ' + t + ' ms');

	// change timeout delay and callback
	timeout.delay = 500;
	timeout.callback = function() {
		console.log('Hello World!');
	};
	// reset timeout
	timeout.set();
}, 1000);

// reset timeout after 500ms
setTimeout(function() {
	timeout.set();
}, 500);

Keywords

FAQs

Package last updated on 26 Feb 2015

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