{"ast":null,"code":"/**\n * Expose `Backoff`.\n */\nmodule.exports = Backoff;\n/**\n * Initialize backoff timer with `opts`.\n *\n * - `min` initial timeout in milliseconds [100]\n * - `max` max timeout [10000]\n * - `jitter` [0]\n * - `factor` [2]\n *\n * @param {Object} opts\n * @api public\n */\n\nfunction Backoff(opts) {\n  opts = opts || {};\n  this.ms = opts.min || 100;\n  this.max = opts.max || 10000;\n  this.factor = opts.factor || 2;\n  this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0;\n  this.attempts = 0;\n}\n/**\n * Return the backoff duration.\n *\n * @return {Number}\n * @api public\n */\n\n\nBackoff.prototype.duration = function () {\n  var ms = this.ms * Math.pow(this.factor, this.attempts++);\n\n  if (this.jitter) {\n    var rand = Math.random();\n    var deviation = Math.floor(rand * this.jitter * ms);\n    ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation;\n  }\n\n  return Math.min(ms, this.max) | 0;\n};\n/**\n * Reset the number of attempts.\n *\n * @api public\n */\n\n\nBackoff.prototype.reset = function () {\n  this.attempts = 0;\n};\n/**\n * Set the minimum duration\n *\n * @api public\n */\n\n\nBackoff.prototype.setMin = function (min) {\n  this.ms = min;\n};\n/**\n * Set the maximum duration\n *\n * @api public\n */\n\n\nBackoff.prototype.setMax = function (max) {\n  this.max = max;\n};\n/**\n * Set the jitter\n *\n * @api public\n */\n\n\nBackoff.prototype.setJitter = function (jitter) {\n  this.jitter = jitter;\n};","map":{"version":3,"sources":["C:/laragon/www/iot.mksolusi/DriverOPCDA/frontend/node_modules/backo2/index.js"],"names":["module","exports","Backoff","opts","ms","min","max","factor","jitter","attempts","prototype","duration","Math","pow","rand","random","deviation","floor","reset","setMin","setMax","setJitter"],"mappings":"AACA;AACA;AACA;AAEAA,MAAM,CAACC,OAAP,GAAiBC,OAAjB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,OAAT,CAAiBC,IAAjB,EAAuB;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,MAAlB,GAA2B,UAASd,GAAT,EAAa;AACtC,OAAKD,EAAL,GAAUC,GAAV;AACD,CAFD;AAIA;AACA;AACA;AACA;AACA;;;AAEAH,OAAO,CAACQ,SAAR,CAAkBU,MAAlB,GAA2B,UAASd,GAAT,EAAa;AACtC,OAAKA,GAAL,GAAWA,GAAX;AACD,CAFD;AAIA;AACA;AACA;AACA;AACA;;;AAEAJ,OAAO,CAACQ,SAAR,CAAkBW,SAAlB,GAA8B,UAASb,MAAT,EAAgB;AAC5C,OAAKA,MAAL,GAAcA,MAAd;AACD,CAFD","sourcesContent":["\n/**\n * Expose `Backoff`.\n */\n\nmodule.exports = Backoff;\n\n/**\n * Initialize backoff timer with `opts`.\n *\n * - `min` initial timeout in milliseconds [100]\n * - `max` max timeout [10000]\n * - `jitter` [0]\n * - `factor` [2]\n *\n * @param {Object} opts\n * @api public\n */\n\nfunction Backoff(opts) {\n  opts = opts || {};\n  this.ms = opts.min || 100;\n  this.max = opts.max || 10000;\n  this.factor = opts.factor || 2;\n  this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0;\n  this.attempts = 0;\n}\n\n/**\n * Return the backoff duration.\n *\n * @return {Number}\n * @api public\n */\n\nBackoff.prototype.duration = function(){\n  var ms = this.ms * Math.pow(this.factor, this.attempts++);\n  if (this.jitter) {\n    var rand =  Math.random();\n    var deviation = Math.floor(rand * this.jitter * ms);\n    ms = (Math.floor(rand * 10) & 1) == 0  ? ms - deviation : ms + deviation;\n  }\n  return Math.min(ms, this.max) | 0;\n};\n\n/**\n * Reset the number of attempts.\n *\n * @api public\n */\n\nBackoff.prototype.reset = function(){\n  this.attempts = 0;\n};\n\n/**\n * Set the minimum duration\n *\n * @api public\n */\n\nBackoff.prototype.setMin = function(min){\n  this.ms = min;\n};\n\n/**\n * Set the maximum duration\n *\n * @api public\n */\n\nBackoff.prototype.setMax = function(max){\n  this.max = max;\n};\n\n/**\n * Set the jitter\n *\n * @api public\n */\n\nBackoff.prototype.setJitter = function(jitter){\n  this.jitter = jitter;\n};\n\n"]},"metadata":{},"sourceType":"script"}