Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function timeout(ms, fn) {
- let timer = setTimeout(() => {
- if (timer) console.log('Function timedout');
- timer = null;
- }, ms);
- return (...args) => {
- if (timer) {
- timer = null;
- fn(...args);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement