Skip to content

Instantly share code, notes, and snippets.

View shoe's full-sized avatar

Chris Shoemaker shoe

View GitHub Profile
@shoe
shoe / interval.js
Created May 9, 2012 02:52 — forked from manast/interval.js
Accurate Javascript setInterval replacement
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