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
有若干和函数(fn1,fn2,....fnn),需要编写一个函数,进行间隔特定的时间执行特定的函数
(fn1,fn2,....fnn)
比如 隔间 1 秒执行 fn1 ,之后间隔 2 秒执行 fn2
fn1
fn2
比如 隔间立即执行 fn1,之后间隔 4 秒执行 fn3
fn3
function sleep (time) { return new Promise((resolve) => setTimeout(resolve, time)); } async function fn(arr){ for(let item of arr){ await sleep(item.time).then(()=>{item.fn()}) } } fn([ { time:1000, fn(){ console.log('1秒后执行fn1') } }, { time:2000, fn(){ console.log('2秒后执行fn2') } } ]) fn([ { time:0, fn(){ console.log('立即执行fn1') } }, { time:4000, fn(){ console.log('4秒后执行fn2') } } ])
The text was updated successfully, but these errors were encountered:
No branches or pull requests
有若干和函数
(fn1,fn2,....fnn)
,需要编写一个函数,进行间隔特定的时间执行特定的函数比如 隔间 1 秒执行
fn1
,之后间隔 2 秒执行fn2
比如 隔间立即执行
fn1
,之后间隔 4 秒执行fn3
The text was updated successfully, but these errors were encountered: