Stabilization process throttle function

The anti-shake function:

= Debounce (FUNC, Delay) => { // stabilization before N seconds after the trigger if performed within N seconds off again, is mainly used for the re-timing Search 
    the let ID = null ;
     return  function (args) { 
      args.persist ( ); 
      the let that = the this , _args = args; 
      the clearTimeout (ID); 
      ID = the setTimeout ( function () { 
        func.call (that, _args); 
      }, Delay); 
    } 
  }

Throttle function:

  = _throttle (FUNC, Delay) => { // throttle provisions can only be triggered once at a time, if triggered multiple times within the time specified, only the first entry into force 
    // Timer release 
    the let Time =   Date.now () ;
     return  function (args) { 
      args.persist (); 
      the let that = the this , _args = args; 
      the let now = Date.now ();
       IF (now - Time> Delay) { 
        func.call (that, _args); 
        Time =   Date.now (); 
      } 
    } 
// timer version
// the let ID = this.id, TH = the this; // return function (args) { // = the this that the let, _args = args; // // id = null can not be determined because each will be reset setstate id = null // the let ID = BOL;! // IF (BOL) {func.call (that , _args);} // IF (th.id) = th.id the setTimeout (function (!) { // th.id = null; // ID = null; // }, Delay) // } }

 

Guess you like

Origin www.cnblogs.com/lisiyang/p/11585553.html