Your IP : 192.168.165.1


Current Path : C:/Users/Mahmood/Desktop/moodle/lib/amd/build/
Upload File :
Current File : C:/Users/Mahmood/Desktop/moodle/lib/amd/build/backoff_timer.min.js.map

{"version":3,"sources":["../src/backoff_timer.js"],"names":["define","BackoffTimer","callback","backoffFunction","backOffFunction","prototype","time","timeout","generateNextTime","newTime","reset","stop","window","clearTimeout","start","setTimeout","bind","restart","getIncrementalCallback","minamount","incrementamount","maxamount","timeoutamount"],"mappings":"AAyBAA,OAAM,sBAAC,UAAW,CAQd,GAAIC,CAAAA,CAAY,CAAG,SAASC,CAAT,CAAmBC,CAAnB,CAAoC,CACnD,KAAKD,QAAL,CAAgBA,CAAhB,CACA,KAAKE,eAAL,CAAuBD,CAC1B,CAHD,CAQAF,CAAY,CAACI,SAAb,CAAuBH,QAAvB,CAAkC,IAAlC,CAKAD,CAAY,CAACI,SAAb,CAAuBD,eAAvB,CAAyC,IAAzC,CAKAH,CAAY,CAACI,SAAb,CAAuBC,IAAvB,CAA8B,IAA9B,CAKAL,CAAY,CAACI,SAAb,CAAuBE,OAAvB,CAAiC,IAAjC,CAYAN,CAAY,CAACI,SAAb,CAAuBG,gBAAvB,CAA0C,UAAW,CACjD,GAAIC,CAAAA,CAAO,CAAG,KAAKL,eAAL,CAAqB,KAAKE,IAA1B,CAAd,CACA,KAAKA,IAAL,CAAYG,CAAZ,CAEA,MAAOA,CAAAA,CACV,CALD,CAaAR,CAAY,CAACI,SAAb,CAAuBK,KAAvB,CAA+B,UAAW,CACtC,KAAKJ,IAAL,CAAY,IAAZ,CACA,KAAKK,IAAL,GAEA,MAAO,KACV,CALD,CAaAV,CAAY,CAACI,SAAb,CAAuBM,IAAvB,CAA8B,UAAW,CACrC,GAAI,KAAKJ,OAAT,CAAkB,CACdK,MAAM,CAACC,YAAP,CAAoB,KAAKN,OAAzB,EACA,KAAKA,OAAL,CAAe,IAClB,CAED,MAAO,KACV,CAPD,CAqBAN,CAAY,CAACI,SAAb,CAAuBS,KAAvB,CAA+B,UAAW,CAEtC,GAAI,CAAC,KAAKP,OAAV,CAAmB,CACf,GAAID,CAAAA,CAAI,CAAG,KAAKE,gBAAL,EAAX,CACA,KAAKD,OAAL,CAAeK,MAAM,CAACG,UAAP,CAAkB,UAAW,CACxC,KAAKb,QAAL,GAEA,KAAKS,IAAL,GAEA,KAAKG,KAAL,EACH,CANgC,CAM/BE,IAN+B,CAM1B,IAN0B,CAAlB,CAMDV,CANC,CAOlB,CAED,MAAO,KACV,CAdD,CAuBAL,CAAY,CAACI,SAAb,CAAuBY,OAAvB,CAAiC,UAAW,CACxC,MAAO,MAAKP,KAAL,GAAaI,KAAb,EACV,CAFD,CAaCb,CAAY,CAACiB,sBAAb,CAAsC,SAASC,CAAT,CAAoBC,CAApB,CAAqCC,CAArC,CAAgDC,CAAhD,CAA+D,CAQlG,MAAO,UAAShB,CAAT,CAAe,CAClB,GAAI,CAACA,CAAL,CAAW,CACP,MAAOa,CAAAA,CACV,CAGD,GAAIb,CAAI,CAAGc,CAAP,CAAyBC,CAA7B,CAAwC,CACpC,MAAOC,CAAAA,CACV,CAED,MAAOhB,CAAAA,CAAI,CAAGc,CACjB,CACJ,CApBA,CAsBD,MAAOnB,CAAAA,CACV,CArJK,CAAN","sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * A timer that will execute a callback with decreasing frequency. Useful for\n * doing polling on the server without overwhelming it with requests.\n *\n * @module     core/backoff_timer\n * @class      backoff_timer\n * @package    core\n * @copyright  2016 Ryan Wyllie <ryan@moodle.com>\n * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\ndefine(function() {\n\n    /**\n     * Constructor for the back off timer.\n     *\n     * @param {function} callback The function to execute after each tick\n     * @param {function} backoffFunction The function to determine what the next timeout value should be\n     */\n    var BackoffTimer = function(callback, backoffFunction) {\n        this.callback = callback;\n        this.backOffFunction = backoffFunction;\n    };\n\n    /**\n     * @type {function} callback The function to execute after each tick\n     */\n    BackoffTimer.prototype.callback = null;\n\n    /**\n     * @type {function} backoffFunction The function to determine what the next timeout value should be\n     */\n    BackoffTimer.prototype.backOffFunction = null;\n\n    /**\n     * @type {int} time The timeout value to use\n     */\n    BackoffTimer.prototype.time = null;\n\n    /**\n     * @type {numeric} timeout The timeout identifier\n     */\n    BackoffTimer.prototype.timeout = null;\n\n    /**\n     * Generate the next timeout in the back off time sequence\n     * for the timer.\n     *\n     * The back off function is called to calculate the next value.\n     * It is given the current value and an array of all previous values.\n     *\n     * @method generateNextTime\n     * @return {int} The new timeout value (in milliseconds)\n     */\n    BackoffTimer.prototype.generateNextTime = function() {\n        var newTime = this.backOffFunction(this.time);\n        this.time = newTime;\n\n        return newTime;\n    };\n\n    /**\n     * Stop the current timer and clear the previous time values\n     *\n     * @method reset\n     * @return {object} this\n     */\n    BackoffTimer.prototype.reset = function() {\n        this.time = null;\n        this.stop();\n\n        return this;\n    };\n\n    /**\n     * Clear the current timeout, if one is set.\n     *\n     * @method stop\n     * @return {object} this\n     */\n    BackoffTimer.prototype.stop = function() {\n        if (this.timeout) {\n            window.clearTimeout(this.timeout);\n            this.timeout = null;\n        }\n\n        return this;\n    };\n\n    /**\n     * Start the current timer by generating the new timeout value and\n     * starting the ticks.\n     *\n     * This function recurses after each tick with a new timeout value\n     * generated each time.\n     *\n     * The callback function is called after each tick.\n     *\n     * @method start\n     * @return {object} this\n     */\n    BackoffTimer.prototype.start = function() {\n        // If we haven't already started.\n        if (!this.timeout) {\n            var time = this.generateNextTime();\n            this.timeout = window.setTimeout(function() {\n                this.callback();\n                // Clear the existing timer.\n                this.stop();\n                // Start the next timer.\n                this.start();\n            }.bind(this), time);\n        }\n\n        return this;\n    };\n\n    /**\n     * Reset the timer and start it again from the initial timeout\n     * values\n     *\n     * @method restart\n     * @return {object} this\n     */\n    BackoffTimer.prototype.restart = function() {\n        return this.reset().start();\n    };\n\n    /**\n     * Returns an incremental function for the timer.\n     *\n     * @param {int} minamount The minimum amount of time we wait before checking\n     * @param {int} incrementamount The amount to increment the timer by\n     * @param {int} maxamount The max amount to ever increment to\n     * @param {int} timeoutamount The timeout to use once we reach the max amount\n     * @return {function}\n     */\n     BackoffTimer.getIncrementalCallback = function(minamount, incrementamount, maxamount, timeoutamount) {\n\n        /**\n         * An incremental function for the timer.\n         *\n         * @param {(int|null)} time The current timeout value or null if none set\n         * @return {int} The new timeout value\n         */\n        return function(time) {\n            if (!time) {\n                return minamount;\n            }\n\n            // Don't go over the max amount.\n            if (time + incrementamount > maxamount) {\n                return timeoutamount;\n            }\n\n            return time + incrementamount;\n        };\n    };\n\n    return BackoffTimer;\n});\n"],"file":"backoff_timer.min.js"}