Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Accurate Javascript setInterval replacement
function interval(duration, fn){
this.baseline = undefined = function(){
if(this.baseline === undefined){
this.baseline = new Date().getTime()
var end = new Date().getTime()
this.baseline += duration
var nextTick = duration - (end - this.baseline)
nextTick = 0
i.timer = setTimeout(function(){
}, nextTick)
this.stop = function(){
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.