Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.22 KB | None | 0 0
  1. function timeout(ms, fn) {
  2. let timer = setTimeout(() => {
  3. if (timer) console.log('Function timedout');
  4. timer = null;
  5. }, ms);
  6. return (...args) => {
  7. if (timer) {
  8. timer = null;
  9. fn(...args);
  10. }
  11. }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement