code: function debounce(callback, delay, lead) {
      var debounceRange = 0;
      var currentTime;
      var lastCall;
      var setDelay;
      var timeoutId;
  
      const call = parameters => {
          callback(parameters);
      };
  
      return parameters => {
          if (lead) {
              currentTime = Date.now();
              if (currentTime > debounceRange) {
                  callback(parameters);
              }
              debounceRange = currentTime + delay;
          } else {
              /**
               * setTimeout is only used with the trail option.
               */
              clearTimeout(timeoutId);
              timeoutId = setTimeout(function () {
                  call(parameters);
              }, delay);
          }
      };
  }
docs: Debounce a function call during repetiton.
  @param {Function}  callback - Callback function.
  @param {Number}    delay    - Delay in milliseconds.
  @param {Boolean}   lead  - Leading or trailing.
  @return {Function} - The debounce function.