nodejs的sleep实现
var mycb=function mycb(arg){
console.log(`in my cb!! arg:${arg}`);
return arg;
四个发展阶段
}
async function timercall(cb, arg, inteval){
夏天的句子短句唯美
let p =new Promi((resolve, reject)=>{
饱学之士
tTimeout(()=>{
学打羽毛球
焦成语//先调⽤cb
let ret =cb(arg);
//返回
resolve({
女生唯美图片callback: cb,
arg,
ret
});
}, inteval);
});
return p;
}
//循环sleep 2S 的⽅法:
父子雄兵下载async function loopedcall(times){
var interval =2000;
for(var i =0; i < times; i++){
var p =await timercall(mycb, i, interval);
console.log(`${i}: call: cbname: ${p.callback.name}, arg: ${p.arg}, ret: ${p.ret}`);
==3){
console.log(`${i}: call end, i will break`);
break;
}
}
想生二胎为什么怀不上}
loopedcall(6);