dist/crocodoc.viewer.js
function (wait, fn) {
            var context,
                args,
                timeout,
                result,
                previous = 0;

            function later () {
                previous = util.now();
                timeout = null;
                result = fn.apply(context, args);
            }

            return function throttled() {
                var now = util.now(),
                    remaining = wait - (now - previous);
                context = this;
                args = arguments;
                if (remaining <= 0) {
                    clearTimeout(timeout);
                    timeout = null;
                    previous = now;
                    result = fn.apply(context, args);
                } else if (!timeout) {
                    timeout = setTimeout(later, remaining);
                }
                return result;
            };
        }
function (wait, fn) {
            var context,
                args,
                timeout,
                result,
                previous = 0;

            function later () {
                previous = util.now();
                timeout = null;
                result = fn.apply(context, args);
            }

            return function throttled() {
                var now = util.now(),
                    remaining = wait - (now - previous);
                context = this;
                args = arguments;
                if (remaining <= 0) {
                    clearTimeout(timeout);
                    timeout = null;
                    previous = now;
                    result = fn.apply(context, args);
                } else if (!timeout) {
                    timeout = setTimeout(later, remaining);
                }
                return result;
            };
        }
function ( wait , fn ) { var context , args , timeout , result , previous = 0 ; function later ( ) { previous = util . now ( ) ; timeout = null ; result = fn . apply ( context , args ) ; } return function throttled ( ) { var now = util . now ( ) , remaining = wait - ( now - previous ) ; context = this ; args = arguments ; if ( remaining <= 0 ) { clearTimeout ( timeout ) ; timeout = null ; previous = now ; result = fn . apply ( context , args ) ; } else if ( ! timeout ) { timeout = setTimeout ( later , remaining ) ; } return result ; } ; }
Creates and returns a new, throttled version of the passed function,
that, when invoked repeatedly, will only actually call the original
function at most once per every wait milliseconds
@param   {int}      wait Time to wait between calls in ms
@param   {Function} fn   The function to throttle
@returns {Function}      The throttled function
Creates and returns a new throttled version of the passed function that when invoked repeatedly will only actually call the original function at most once per every wait milliseconds