Skip to content

aaronik/accurate_timer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 

Repository files navigation

An accurate, multienvironment timer

accurate_timer uses requestAnimationFrame() and performance.now(), defaulting to setInterval if it's used in a non-browser or older environment.

Based on my own (unscientific) measurements, the timer in a node.js environment tends to be accurate to about 3/1000ths of a second. In a browser environment it's a little less than 1/1000ths of a second.

Usage

  • Create a timer object:

     var timer = new Timer(<callback>, <interval>);

    The callback will be called every interval milliseconds.

  • start / stop the timer:

     timer.start();
     timer.stop();

All done! I hope you enjoy 😊

About

An accurate timer written in javascript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •