code: function throttle(f, delay) {
    var timeoutId;
    var previous = 0;
  
    return function throttleExecute_() {
      var args = arguments;
      var now = +(new Date());
      var remaining = delay - (now - previous);
  
      if (remaining <= 0) {
        clearTimeout(timeoutId);
        timeoutId = null;
        previous = now;
  
        f.apply(null, args);
      } else if (!timeoutId) {
        timeoutId = setTimeout(function() {
          previous = +(new Date());
          timeoutId = null;
  
          f.apply(null, args);
        }, remaining);
      }
    };
  }
docs: Throttle a function.
  @param {function} f The function.
  @param {number} delay The delay in ms.
  @return {function} A function which calls the passed-in function throttled.