Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris Shoemaker shoe

View GitHub Profile
@shoe
shoe / interval.js
Created May 9, 2012 — forked from manast/interval.js
Accurate Javascript setInterval replacement
View interval.js
function interval(duration, fn){
this.baseline = undefined
this.run = function(){
if(this.baseline === undefined){
this.baseline = new Date().getTime()
}
fn()
var end = new Date().getTime()
this.baseline += duration