Skip to content

Instantly share code, notes, and snippets.

@sparr
Last active March 12, 2017 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sparr/4a56238e233d14470d7b7c0211a9bdb2 to your computer and use it in GitHub Desktop.
Save sparr/4a56238e233d14470d7b7c0211a9bdb2 to your computer and use it in GitHub Desktop.
clear active timers in Javascript
for (handle of process._getActiveHandles()) {
// if (handle instanceof Timer) { // doesn't work because Timer isn't defined, even though handle.constructor.name=="Timer"
if ('_list' in handle) {
for (timername in handle._list) {
clearTimeout(handle._list[timername]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment