later = function () {
      timeout = null;
      if (!immediate) func.apply(context, args);
    }
Returns debounce function that gets called only once after a set of repeated calls.

@param {function} functionToDebounce
@param {number} wait - Time to wait for repeated function calls (milliseconds).
@param {boolean} immediate - Calls the function immediately regardless of if it should be waiting.
@returns {function} Debounced function.