docs: function debounce(method, delay, leading) {
    assertType(method, 'function', false, 'Invalid parameter: method');
    assertType(delay, 'number', true, 'Invalid optional parameter: delay');
    assertType(leading, 'boolean', true, 'Invalid optional parameter: leading');
  
    if (delay === undefined) delay = 0;
    if (leading === undefined) leading = false;
  
    let timeout;
  
    return function() {
      let context = this;
      let args = arguments;
  
      let later = function() {
        timeout = null;
        if (!leading) method.apply(context, args);
      };
  
      let callNow = leading && !timeout;
      clearTimeout(timeout);
      timeout = setTimeout(later, delay);
  
      if (callNow) method.apply(context, args);
    };
  }