SOURCE

function SetInterVal(fn,a,b){
    this.fn=fn
    this.start=a
    this.timeStep=b
    this.times=0
    this.clearTimer=false
    this.task=()=>{
        this.timer= setTimeout(()=>{
            this.fn && this.fn()
            console.log(`时间间隔。。。${this.start+this.times*this.timeStep}`)
            this.next()
        },(this.start+this.times*this.timeStep))
    }
    setTimeout(this.task,0)
}

SetInterVal.prototype.next=function(){
    this.times++
    if(!this.clearTimer)
    this.task()
}


function mySetInterVal(fn,a,b){
    return new SetInterVal(fn,a,b)
}

// mySetInterVal(()=>{
//     console.log('testing...')
// },100,50)

function myClear(){
    mySetInterVal.clearTimer=true
}
myClear()
console 命令行工具 X clear

                    
>
console