Skip to content

Instantly share code, notes, and snippets.

View weednation12's full-sized avatar

Lasse Andersen weednation12

  • Chopenhagen, Denmark
View GitHub Profile
@manast
manast / interval.js
Last active November 15, 2023 22:08
Accurate Javascript setInterval replacement
function interval(duration, fn){
var _this = this
this.baseline = undefined
this.run = function(){
if(_this.baseline === undefined){
_this.baseline = new Date().getTime()
}
fn()
var end = new Date().getTime()