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

            function later() {
                var last = util.now() - timestamp;
                if (last < wait) {
                    timeout = setTimeout(later, wait - last);
                } else {
                    timeout = null;
                    result = fn.apply(context, args);
                    context = args = null;
                }
            }

            return function debounced() {
                context = this;
                args = arguments;
                timestamp = util.now();
                if (!timeout) {
                    timeout = setTimeout(later, wait);
                }
                return result;
            };
        }
function (wait, fn) {
            var context,
                args,
                timeout,
                timestamp,
                result;

            function later() {
                var last = util.now() - timestamp;
                if (last < wait) {
                    timeout = setTimeout(later, wait - last);
                } else {
                    timeout = null;
                    result = fn.apply(context, args);
                    context = args = null;
                }
            }

            return function debounced() {
                context = this;
                args = arguments;
                timestamp = util.now();
                if (!timeout) {
                    timeout = setTimeout(later, wait);
                }
                return result;
            };
        }
function ( wait , fn ) { var context , args , timeout , timestamp , result ; function later ( ) { var last = util . now ( ) - timestamp ; if ( last < wait ) { timeout = setTimeout ( later , wait - last ) ; } else { timeout = null ; result = fn . apply ( context , args ) ; context = args = null ; } } return function debounced ( ) { context = this ; args = arguments ; timestamp = util . now ( ) ; if ( ! timeout ) { timeout = setTimeout ( later , wait ) ; } return result ; } ; }
Creates and returns a new debounced version of the passed function
which will postpone its execution until after wait milliseconds
have elapsed since the last time it was invoked.
@param   {int}      wait Time to wait between calls in ms
@param   {Function} fn   The function to debounced
@returns {Function}      The debounced function
Creates and returns a new debounced version of the passed function which will postpone its execution until after wait milliseconds have elapsed since the last time it was invoked .