code: function wrapper() {
        var that = this,
          elapsed = +new Date() - last_exec,
          args = arguments;
        
        // Execute `callback` and update the `last_exec` timestamp.
        function exec() {
          last_exec = +new Date();
          callback.apply( that, args );
        };
        
        // If `debounce_mode` is true (at_begin) this is used to clear the flag
        // to allow future `callback` executions.
        function clear() {
          timeout_id = undefined;
        };
        
        if ( debounce_mode && !timeout_id ) {
          // Since `wrapper` is being called for the first time and
          // `debounce_mode` is true (at_begin), execute `callback`.
          exec();
        }
        
        // Clear any existing timeout.
        timeout_id && clearTimeout( timeout_id );
        
        if ( debounce_mode === undefined && elapsed > delay ) {
          // In throttle mode, if `delay` time has been exceeded, execute
          // `callback`.
          exec();
          
        } else if ( no_trailing !== true ) {
          // In trailing throttle mode, since `delay` time has not been
          // exceeded, schedule `callback` to execute `delay` ms after most
          // recent execution.
          // 
          // If `debounce_mode` is true (at_begin), schedule `clear` to execute
          // after `delay` ms.
          // 
          // If `debounce_mode` is false (at end), schedule `callback` to
          // execute after `delay` ms.
          timeout_id = setTimeout( debounce_mode ? clear : exec, debounce_mode === undefined ? delay - elapsed : delay );
        }
      }
docs: The `wrapper` function encapsulates all of the throttling / debouncing functionality and when executed will limit the rate at which `callback` is executed.