petite-utils • Docs
函数: repeatRun() 
repeatRun(
fn,__namedParameters,params?):StopRepeat
repeat call function 
参数 
| 参数名 | 类型 | 描述 | 
|---|---|---|
fn | RepeatFn | will be called repeatly | 
__namedParameters | RepeatOptions | - | 
params? | unknown | params pass to fn | 
返回值 
stopFunction to stop repeat
示例s 
pass a arrow function to repeat 
ts
repeatRun((repeatTimes, stop) => {
 console.log(repeatTimes)
if (repeatTimes === 5) {
   stop() // stop function from fn params
 }
})pass a function definition to repeat and stop it by repeat return value 
ts
let stop = repeatRun(sayHi, { interval: 1000 })
function sayHi(repeatTimes) {
 console.log(repeatTimes)
 if (repeatTimes === 5) {
  stop() // stop from repeatRun return value
 }
}