Skip to content

Instantly share code, notes, and snippets.

@Patrolin
Last active August 20, 2021 13:34
Show Gist options
  • Save Patrolin/09e5dfe584d43830333d8f6c1ebfc04c to your computer and use it in GitHub Desktop.
Save Patrolin/09e5dfe584d43830333d8f6c1ebfc04c to your computer and use it in GitHub Desktop.
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