function debounce()

in src/js/utils/debounce.js [18:36]


function debounce(func, wait, immediate = false) {
  let timeout;
  return function() {
    var context = this;
    var args = arguments;
    var later = function() {
      timeout = null;
      if (!immediate) {
        func.call(context, args);
      }
    };
    var callNow = immediate && !timeout;
    clearTimeout(timeout);
    timeout = setTimeout(later, wait);
    if (callNow) {
      func.call(context, args);
    }
  };
}