Socket
Socket
Sign inDemoInstall

clock-interval

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    clock-interval

A precise interval timer pinned to system clock


Version published
Weekly downloads
4
increased by300%
Maintainers
1
Install size
26.5 kB
Created
Weekly downloads
 

Readme

Source

perfect-interval

A precise interval timer pinned to system clock

How to use

npm install clock-interval
Example usage

Update an element with the currnt time

var clockInterval = require('clock-interval');

function pad(num) {
  return ('0' + num).slice(-2);
}
  
clockInterval(function() {
    var clockEl = document.getElementById('clock'),
        dateObj = new Date(); 
      clockEl.innerHTML = pad(dateObj.getHours()) + ':' + pad(dateObj.getMinutes()) + ':' + pad(dateObj.getSeconds());
});

Cancel the interval

var timer = clockInterval(function() {});

// Cancel the timer
timer.cancel();

Why not use setInterval?

FAQs

Last updated on 04 Aug 2015

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc