src/core.js
function(func, wait) {
        var self = this,
            timeout,
            // args, // right now there is no need for arguments
            // context, // and for context
            timestamp
            // result // and for result

        var later = function() {
            if (self._disposed) {
                clearTimeout(timeout)
                timeout = self = null
                return
            }

            var last = getTime() - timestamp

            if (last < wait && last >= 0) {
                timeout = setTimeout(later, wait - last)
            } else {
                timeout = null
                // result = func.apply(context, args)
                func()
                // context = args = null
            }
        }

        return function() {
            // context = this
            // args = arguments
            timestamp = getTime()

            if (!timeout) {
                timeout = setTimeout(later, wait)
            }

            // return result
        }
    }
function(func, wait) {
        var self = this,
            timeout,
            // args, // right now there is no need for arguments
            // context, // and for context
            timestamp
            // result // and for result

        var later = function() {
            if (self._disposed) {
                clearTimeout(timeout)
                timeout = self = null
                return
            }

            var last = getTime() - timestamp

            if (last < wait && last >= 0) {
                timeout = setTimeout(later, wait - last)
            } else {
                timeout = null
                // result = func.apply(context, args)
                func()
                // context = args = null
            }
        }

        return function() {
            // context = this
            // args = arguments
            timestamp = getTime()

            if (!timeout) {
                timeout = setTimeout(later, wait)
            }

            // return result
        }
    }
function ( func , wait ) { var self = this , timeout , // args, // right now there is no need for arguments // context, // and for context timestamp // result // and for result var later = function ( ) { if ( self . _disposed ) { clearTimeout ( timeout ) timeout = self = null return } var last = getTime ( ) - timestamp if ( last < wait && last >= 0 ) { timeout = setTimeout ( later , wait - last ) } else { timeout = null // result = func.apply(context, args) func ( ) // context = args = null } } return function ( ) { // context = this // args = arguments timestamp = getTime ( ) if ( ! timeout ) { timeout = setTimeout ( later , wait ) } // return result } }
underscore.js realization used in autoUpdate plugin
underscore . js realization used in autoUpdate plugin