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
延时函数:等待一段时间,再继续进行
//Promise const sleep = time => { return new Promise(resolve => setTimeout(resolve,time)) } sleep(1000).then(()=>{ console.log(1) })
//Generator function* sleepGenerator(time) { yield new Promise(function(resolve,reject){ setTimeout(resolve,time); }) } sleepGenerator(1000).next().value.then(()=>{console.log(1)})
//async function sleep(time) { return new Promise(resolve => setTimeout(resolve,time)) } async function output() { let out = await sleep(1000); console.log(1); return out; } output();
//ES5 function sleep(callback,time) { if(typeof callback === 'function') setTimeout(callback,time) } function output(){ console.log(1); } sleep(output,1000);
实现一个 sleep 函数
The text was updated successfully, but these errors were encountered:
sihai00
No branches or pull requests
sleep函数
延时函数:等待一段时间,再继续进行
Promise
Generator
async
es5
参考
实现一个 sleep 函数
The text was updated successfully, but these errors were encountered: