Last active
August 20, 2021 13:34
-
-
Save Patrolin/09e5dfe584d43830333d8f6c1ebfc04c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (typeof cheat === 'undefined') cheat = { | |
intervals: {}, | |
start(f, s){ | |
if (!f.name) throw 'function must have a name'; | |
try {this.stop(f.name)} catch {}; | |
this.intervals[f.name] = setInterval(f, s); | |
}, | |
stop(name){ | |
if (this.intervals[name] === undefined) throw `${name} does not exist`; | |
clearInterval(this.intervals[name]); | |
delete this.intervals[name]; | |
}, | |
stopAll(){ | |
Object.keys(this.intervals).forEach(name => this.stop(name)); | |
}, | |
qed: 'qed', | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment