We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
function mySetInterval(fn, a, b){ let timer = null let count = 0 let timestamp // 设置定时器 function set(){ const step = count % 3 switch(step){ case 0: timestamp = a; break; case 1: timestamp = a + b break; case 2: timestamp = a + 2 * b break; } timer = setTimeout(()=>{ fn() count++ set() }, timestamp * 1000) } // 清除定时器 function clear(){ timer && clearTimeout(timer) } set() return clear } function out(){ console.log(new Date().getSeconds()) } const clear = mySetInterval(out,1,2) setTimeout(()=>{clear()},20000)
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: