dist/hawtio-utilities.js
function throttled(fn, millis) {
        var nextInvokeTime = 0;
        var lastAnswer = null;
        return function () {
            var now = Date.now();
            if (nextInvokeTime < now) {
                nextInvokeTime = now + millis;
                lastAnswer = fn();
            }
            else {
                //log.debug("Not invoking function as we did call " + (now - (nextInvokeTime - millis)) + " ms ago");
            }
            return lastAnswer;
        };
    }
function throttled(fn, millis) {
        var nextInvokeTime = 0;
        var lastAnswer = null;
        return function () {
            var now = Date.now();
            if (nextInvokeTime < now) {
                nextInvokeTime = now + millis;
                lastAnswer = fn();
            }
            else {
                //log.debug("Not invoking function as we did call " + (now - (nextInvokeTime - millis)) + " ms ago");
            }
            return lastAnswer;
        };
    }
function throttled ( fn , millis ) { var nextInvokeTime = 0 ; var lastAnswer = null ; return function ( ) { var now = Date . now ( ) ; if ( nextInvokeTime < now ) { nextInvokeTime = now + millis ; lastAnswer = fn ( ) ; } else { //log.debug("Not invoking function as we did call " + (now - (nextInvokeTime - millis)) + " ms ago"); } return lastAnswer ; } ; }
Returns a new function which ensures that the delegate function is only invoked at most once
within the given number of millseconds
@method throttled
@for Core
@static
@param {Function} fn the function to be invoked at most once within the given number of millis
@param {Number} millis the time window during which this function should only be called at most once
@return {Object}
Returns a new function which ensures that the delegate function is only invoked at most once within the given number of millseconds