Created
March 14, 2018 17:31
-
-
Save mendes5/400468468b47ce8794894c07a7b7b444 to your computer and use it in GitHub Desktop.
Provides `clearAllTimeouts()` and `clearAllIntervals()`.
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
| (()=>{ | |
| const timeout = window.setTimeout, interval = window.setInterval | |
| let intervals = [], timeouts = [] | |
| window.setTimeout = (cb, tm, rv) => (timeouts.push(rv = timeout(cb, tm)), rv) | |
| window.setInterval = (cb, tm, rv) => (intervals.push(rv = interval(cb, tm)), rv) | |
| window.clearAllTimeouts = () => {timeouts.map(e => clearTimeout(e)); timeouts = []} | |
| window.clearAllIntervals = () => {intervals.map(e => clearInterval(e)); intervals = []} | |
| })() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment