// repeat(fn, 5, 1000);
// 返回一个函数,调用后1000s,执行函数fn,一共重复五次
function repeat(fn, time, wait){
return function callback(...arg){
const t = setTimeout(()=>{
fn(arg)
time--
if(time>0){
callback(...arg)
}
clearTimeout(t)
}, wait)
}
}
// test region
function test(arg){
console.log(arg)
}
repeat(test,5,1000)("test")