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

clocktick

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

clocktick

Clock-accurate timeout for Node.js and browser

  • 0.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by75%
Maintainers
1
Weekly downloads
 
Created
Source

clocktick

Clock-accurate timeout for Node.js and browser. Basically it is identical to setTimeout, but it triggers callback function precisely on the next second.

example

See an example here

accuracy

Accuracy should be around 1–2ms.

installation

npm install clocktick

usage

Usage is similar to setTimeout, but without delay parameter:

var tick = require('clocktick')
tick(callback) // Ticks every second

You can use the delay parameter, but it is in seconds:

tick(callback, 2) // Ticks on 2nd second (00, 02, 04, 06, 08, 10,...)

You can also offset seconds:

tick(callback, 3) // Ticks on 3rd second (03, 06, 9, 12, 15, 18, ...)
tick(callback, 3, 1) // Ticks on 3rd+1 second (04, 07, 10, 13, 16, 19, ...)
tick(callback, 3, 2) // Ticks on 3rd+2 second (05, 08, 11, 14, 17, 20, ...)

repeat

You can repeat the tick by just calling it again:

tick(callback)

function callback () {
  console.log('tick')
  tick(callback)
}

cancel

You can cancel the tick by using clearTimeout:

var timeout = tick(callback)

clearTimeout(timeout)

testing

Clone to desktop and then run following commands at clocktick folder:

npm install
npm test

building

npm install
npm run build

FAQs

Package last updated on 09 Jul 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