SOURCE

var TimeDelay = {
     pool:{},
     clearAll(){
         Object.keys(TimeDelay.pool).forEach((item)=>{
             if(TimeDelay.pool[item]){
                 clearTimeout(TimeDelay.pool[item]);
                 delete TimeDelay.pool[item]
             }
         })
      

     },
     addTimeout(name=null,fn=null,delay=0){
        if(!name || typeof fn !== 'function'){
            
            throw new Error('addTimeout对象参数错误');
        }
        if(TimeDelay.pool[name]){
            //throw new Error('已经存在相同的setTimeout对象')
            console.warn('已经存在相同的setTimeout对象')
            TimeDelay.delTimeout(name);
        }
        TimeDelay.pool[name] = setTimeout(()=>{
            fn();
            
            
        },delay);
    
    },
     delTimeout(name=null){
         if(TimeDelay.pool[name]){
             clearTimeout(TimeDelay.pool[name]);
             delete TimeDelay.pool[name];

         }
    
    }
}
console 命令行工具 X clear

                    
>
console