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 = ; duration: 1000 { var hours = Math % 24; var minutes = Math % 60; var seconds = 1000 / timerduration * timertotal_ticks % 60; console; };
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.