🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

hires-timer

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

hires-timer

A high-resolution timer with callback

0.1.0
latest
Source
npm
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

hires-timer

A high-resolution timer with callback, based on this origional timer, but modified to be more accurate on low-power devices where the timer accuracy is less guarenteed.

Getting Started

Install the module with: npm install hires-timer

var HighResolutionTimer = require('hires-timer');
new HighResolutionTimer({
  duration: 1000,
  callback: function(timer) {
    var hours = Math.floor( ( ( (1000 / timer.duration) * timer.total_ticks) / 60) / 24) % 24;
    var minutes = Math.floor( ( (1000 / timer.duration) * timer.total_ticks) / 60) % 60;
    var seconds = ( (1000 / timer.duration) * timer.total_ticks) % 60;
    console.log(hours, minutes, seconds);
  }
});

Including in the browser

Include the file as a script instead

<script src="highres-timer.js"></script>
<script>
var timer = new HighResolutionTimer({
  duration: 1000,
  callback: function(timer) {
    var hours = Math.floor( ( ( (1000 / timer.duration) * timer.total_ticks) / 60) / 24) % 24;
    var minutes = Math.floor( ( (1000 / timer.duration) * timer.total_ticks) / 60) % 60;
    var seconds = ( (1000 / timer.duration) * timer.total_ticks) % 60;
    console.log(hours, minutes, seconds);
  }
});

License

Copyright (c) 2012 Tane Piper
Licensed under the MIT license.

FAQs

Package last updated on 05 Dec 2012

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