Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

opossum

Package Overview
Dependencies
Maintainers
5
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opossum - npm Package Compare versions

Comparing version 6.0.0 to 6.0.1

8

CHANGELOG.md

@@ -5,2 +5,10 @@ # Changelog

### [6.0.1](https://www.github.com/nodeshift/opossum/compare/v6.0.0...v6.0.1) (2021-04-15)
### Bug Fixes
* return errors from invocation filtered errors ([#567](https://www.github.com/nodeshift/opossum/issues/567)) ([737e1b1](https://www.github.com/nodeshift/opossum/commit/737e1b1bbd5e440791d0b06f5b837073c0d2bdbf)), closes [#556](https://www.github.com/nodeshift/opossum/issues/556)
* **docs:** Fix documentation for default value of rollingPercentilesEnabled ([#563](https://www.github.com/nodeshift/opossum/issues/563)) ([93d5969](https://www.github.com/nodeshift/opossum/commit/93d59697c614a4b567fee63d76201f151a6ecef8))
## [6.0.0](https://www.github.com/nodeshift/opossum/compare/v5.1.3...v6.0.0) (2021-03-18)

@@ -7,0 +15,0 @@

2

dist/opossum.min.js

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.circuitBreaker=t():e.circuitBreaker=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=4)}([function(e,t,n){(function(t){var r=n(2),o=n(9);function i(){return(new Date).getTime()}var u,c=Array.prototype.slice,s={};u=void 0!==t&&t.console?t.console:"undefined"!=typeof window&&window.console?window.console:{};for(var a=[[function(){},"log"],[function(){u.log.apply(u,arguments)},"info"],[function(){u.log.apply(u,arguments)},"warn"],[function(){u.warn.apply(u,arguments)},"error"],[function(e){s[e]=i()},"time"],[function(e){var t=s[e];if(!t)throw new Error("No such label: "+e);delete s[e];var n=i()-t;u.log(e+": "+n+"ms")},"timeEnd"],[function(){var e=new Error;e.name="Trace",e.message=r.format.apply(null,arguments),u.error(e.stack)},"trace"],[function(e){u.log(r.inspect(e)+"\n")},"dir"],[function(e){if(!e){var t=c.call(arguments,1);o.ok(!1,r.format.apply(null,t))}},"assert"]],f=0;f<a.length;f++){var l=a[f],p=l[0],h=l[1];u[h]||(u[h]=p)}e.exports=u}).call(this,n(1))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){(function(e,r){var o=Object.getOwnPropertyDescriptors||function(e){for(var t=Object.keys(e),n={},r=0;r<t.length;r++)n[t[r]]=Object.getOwnPropertyDescriptor(e,t[r]);return n},i=/%[sdj%]/g;t.format=function(e){if(!b(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(s(arguments[n]));return t.join(" ")}n=1;for(var r=arguments,o=r.length,u=String(e).replace(i,(function(e){if("%%"===e)return"%";if(n>=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),c=r[n];n<o;c=r[++n])v(c)||!O(c)?u+=" "+c:u+=" "+s(c);return u},t.deprecate=function(n,o){if(void 0!==e&&!0===e.noDeprecation)return n;if(void 0===e)return function(){return t.deprecate(n,o).apply(this,arguments)};var i=!1;return function(){if(!i){if(e.throwDeprecation)throw new Error(o);e.traceDeprecation?r.trace(o):r.error(o),i=!0}return n.apply(this,arguments)}};var u,c={};function s(e,n){var r={seen:[],stylize:f};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),m(n)?r.showHidden=n:n&&t._extend(r,n),g(r.showHidden)&&(r.showHidden=!1),g(r.depth)&&(r.depth=2),g(r.colors)&&(r.colors=!1),g(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=a),l(r,e,r.depth)}function a(e,t){var n=s.styles[t];return n?"["+s.colors[n][0]+"m"+e+"["+s.colors[n][1]+"m":e}function f(e,t){return e}function l(e,n,r){if(e.customInspect&&n&&x(n.inspect)&&n.inspect!==t.inspect&&(!n.constructor||n.constructor.prototype!==n)){var o=n.inspect(r,e);return b(o)||(o=l(e,o,r)),o}var i=function(e,t){if(g(t))return e.stylize("undefined","undefined");if(b(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}if(d(t))return e.stylize(""+t,"number");if(m(t))return e.stylize(""+t,"boolean");if(v(t))return e.stylize("null","null")}(e,n);if(i)return i;var u=Object.keys(n),c=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(u);if(e.showHidden&&(u=Object.getOwnPropertyNames(n)),j(n)&&(u.indexOf("message")>=0||u.indexOf("description")>=0))return p(n);if(0===u.length){if(x(n)){var s=n.name?": "+n.name:"";return e.stylize("[Function"+s+"]","special")}if(w(n))return e.stylize(RegExp.prototype.toString.call(n),"regexp");if(E(n))return e.stylize(Date.prototype.toString.call(n),"date");if(j(n))return p(n)}var a,f="",O=!1,S=["{","}"];(y(n)&&(O=!0,S=["[","]"]),x(n))&&(f=" [Function"+(n.name?": "+n.name:"")+"]");return w(n)&&(f=" "+RegExp.prototype.toString.call(n)),E(n)&&(f=" "+Date.prototype.toUTCString.call(n)),j(n)&&(f=" "+p(n)),0!==u.length||O&&0!=n.length?r<0?w(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special"):(e.seen.push(n),a=O?function(e,t,n,r,o){for(var i=[],u=0,c=t.length;u<c;++u)_(t,String(u))?i.push(h(e,t,n,r,String(u),!0)):i.push("");return o.forEach((function(o){o.match(/^\d+$/)||i.push(h(e,t,n,r,o,!0))})),i}(e,n,r,c,u):u.map((function(t){return h(e,n,r,c,t,O)})),e.seen.pop(),function(e,t,n){if(e.reduce((function(e,t){return t.indexOf("\n")>=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1];return n[0]+t+" "+e.join(", ")+" "+n[1]}(a,f,S)):S[0]+f+S[1]}function p(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,n,r,o,i){var u,c,s;if((s=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]}).get?c=s.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):s.set&&(c=e.stylize("[Setter]","special")),_(r,o)||(u="["+o+"]"),c||(e.seen.indexOf(s.value)<0?(c=v(n)?l(e,s.value,null):l(e,s.value,n-1)).indexOf("\n")>-1&&(c=i?c.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+c.split("\n").map((function(e){return" "+e})).join("\n")):c=e.stylize("[Circular]","special")),g(u)){if(i&&o.match(/^\d+$/))return c;(u=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(u=u.substr(1,u.length-2),u=e.stylize(u,"name")):(u=u.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),u=e.stylize(u,"string"))}return u+": "+c}function y(e){return Array.isArray(e)}function m(e){return"boolean"==typeof e}function v(e){return null===e}function d(e){return"number"==typeof e}function b(e){return"string"==typeof e}function g(e){return void 0===e}function w(e){return O(e)&&"[object RegExp]"===S(e)}function O(e){return"object"==typeof e&&null!==e}function E(e){return O(e)&&"[object Date]"===S(e)}function j(e){return O(e)&&("[object Error]"===S(e)||e instanceof Error)}function x(e){return"function"==typeof e}function S(e){return Object.prototype.toString.call(e)}function T(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(n){if(g(u)&&(u=Object({WEB:"web"}).NODE_DEBUG||""),n=n.toUpperCase(),!c[n])if(new RegExp("\\b"+n+"\\b","i").test(u)){var o=e.pid;c[n]=function(){var e=t.format.apply(t,arguments);r.error("%s %d: %s",n,o,e)}}else c[n]=function(){};return c[n]},t.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=y,t.isBoolean=m,t.isNull=v,t.isNullOrUndefined=function(e){return null==e},t.isNumber=d,t.isString=b,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=g,t.isRegExp=w,t.isObject=O,t.isDate=E,t.isError=j,t.isFunction=x,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=n(7);var k=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function P(){var e=new Date,t=[T(e.getHours()),T(e.getMinutes()),T(e.getSeconds())].join(":");return[e.getDate(),k[e.getMonth()],t].join(" ")}function _(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){r.log("%s - %s",P(),t.format.apply(t,arguments))},t.inherits=n(8),t._extend=function(e,t){if(!t||!O(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e};var L="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function A(e,t){if(!e){var n=new Error("Promise was rejected with a falsy value");n.reason=e,e=n}return t(e)}t.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(L&&e[L]){var t;if("function"!=typeof(t=e[L]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,L,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,n,r=new Promise((function(e,r){t=e,n=r})),o=[],i=0;i<arguments.length;i++)o.push(arguments[i]);o.push((function(e,r){e?n(e):t(r)}));try{e.apply(this,o)}catch(e){n(e)}return r}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),L&&Object.defineProperty(t,L,{value:t,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(t,o(e))},t.promisify.custom=L,t.callbackify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');function n(){for(var n=[],r=0;r<arguments.length;r++)n.push(arguments[r]);var o=n.pop();if("function"!=typeof o)throw new TypeError("The last argument must be of type Function");var i=this,u=function(){return o.apply(i,arguments)};t.apply(this,n).then((function(t){e.nextTick(u,null,t)}),(function(t){e.nextTick(A,t,u)}))}return Object.setPrototypeOf(n,Object.getPrototypeOf(t)),Object.defineProperties(n,o(t)),n}}).call(this,n(6),n(0))},function(e,t,n){"use strict";(function(t){var n,r="object"==typeof Reflect?Reflect:null,o=r&&"function"==typeof r.apply?r.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};n=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function u(){u.init.call(this)}e.exports=u,e.exports.once=function(e,t){return new Promise((function(n,r){function o(n){e.removeListener(t,i),r(n)}function i(){"function"==typeof e.removeListener&&e.removeListener("error",o),n([].slice.call(arguments))}v(e,t,i,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&v(e,"error",t,n)}(e,o,{once:!0})}))},u.EventEmitter=u,u.prototype._events=void 0,u.prototype._eventsCount=0,u.prototype._maxListeners=void 0;var c=10;function s(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function a(e){return void 0===e._maxListeners?u.defaultMaxListeners:e._maxListeners}function f(e,n,r,o){var i,u,c,f;if(s(r),void 0===(u=e._events)?(u=e._events=Object.create(null),e._eventsCount=0):(void 0!==u.newListener&&(e.emit("newListener",n,r.listener?r.listener:r),u=e._events),c=u[n]),void 0===c)c=u[n]=r,++e._eventsCount;else if("function"==typeof c?c=u[n]=o?[r,c]:[c,r]:o?c.unshift(r):c.push(r),(i=a(e))>0&&c.length>i&&!c.warned){c.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+c.length+" "+String(n)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=n,l.count=c.length,f=l,t&&t.warn&&t.warn(f)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=l.bind(r);return o.listener=n,r.wrapFn=o,o}function h(e,t,n){var r=e._events;if(void 0===r)return[];var o=r[t];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(o):m(o,o.length)}function y(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function m(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function v(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function o(i){r.once&&e.removeEventListener(t,o),n(i)}))}}Object.defineProperty(u,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");c=e}}),u.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},u.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},u.prototype.getMaxListeners=function(){return a(this)},u.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var u;if(t.length>0&&(u=t[0]),u instanceof Error)throw u;var c=new Error("Unhandled error."+(u?" ("+u.message+")":""));throw c.context=u,c}var s=i[e];if(void 0===s)return!1;if("function"==typeof s)o(s,this,t);else{var a=s.length,f=m(s,a);for(n=0;n<a;++n)o(f[n],this,t)}return!0},u.prototype.addListener=function(e,t){return f(this,e,t,!1)},u.prototype.on=u.prototype.addListener,u.prototype.prependListener=function(e,t){return f(this,e,t,!0)},u.prototype.once=function(e,t){return s(t),this.on(e,p(this,e,t)),this},u.prototype.prependOnceListener=function(e,t){return s(t),this.prependListener(e,p(this,e,t)),this},u.prototype.removeListener=function(e,t){var n,r,o,i,u;if(s(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(o=-1,i=n.length-1;i>=0;i--)if(n[i]===t||n[i].listener===t){u=n[i].listener,o=i;break}if(o<0)return this;0===o?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,o),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,u||t)}return this},u.prototype.off=u.prototype.removeListener,u.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var o,i=Object.keys(n);for(r=0;r<i.length;++r)"removeListener"!==(o=i[r])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},u.prototype.listeners=function(e){return h(this,e,!0)},u.prototype.rawListeners=function(e){return h(this,e,!1)},u.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):y.call(e,t)},u.prototype.listenerCount=y,u.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}}).call(this,n(0))},function(e,t,n){"use strict";e.exports=n(5)},function(e,t,n){"use strict";(function(t){function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=p(e);if(t){var o=p(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return f(this,n)}}function f(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?l(e):t}function l(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var h=n(3),y=n(11),m=n(12),v=Symbol("state"),d=Symbol("open"),b=Symbol("closed"),g=Symbol("half-open"),w=Symbol("pending-close"),O=Symbol("shutdown"),E=Symbol("fallback"),j=Symbol("status"),x=Symbol("name"),S=Symbol("group"),T=new WeakMap,k=Symbol("Enabled"),P=Symbol("warming-up"),_=Symbol("volume-threshold"),L=Symbol("our-error"),A=Symbol("reset-timeout"),C=Symbol("warmup-timeout"),D="options.maxFailures is deprecated. Please use options.errorThresholdPercentage",M=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(f,e);var n,r,o,i=a(f);function f(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(u(this,f),(n=i.call(this)).options=r,n.options.timeout=!1!==r.timeout&&(r.timeout||1e4),n.options.resetTimeout=r.resetTimeout||3e4,n.options.errorThresholdPercentage=r.errorThresholdPercentage||50,n.options.rollingCountTimeout=r.rollingCountTimeout||1e4,n.options.rollingCountBuckets=r.rollingCountBuckets||10,n.options.rollingPercentilesEnabled=!1!==r.rollingPercentilesEnabled,n.options.capacity=Number.isInteger(r.capacity)?r.capacity:Number.MAX_SAFE_INTEGER,n.options.errorFilter=r.errorFilter||function(e){return!1},n.semaphore=new m(n.options.capacity),!e)throw new TypeError("No action provided. Cannot construct a CircuitBreaker without an invocable action.");if(n[_]=Number.isInteger(r.volumeThreshold)?r.volumeThreshold:0,n[P]=!0===r.allowWarmUp,n[j]=new y(n.options),n[v]=b,n[E]=null,n[w]=!1,n[x]=r.name||e.name||N(),n[S]=r.group||n[x],n[k]=!1!==r.enabled,n[P]){var o=n[C]=setTimeout((function(e){return n[P]=!1}),n.options.rollingCountTimeout);"function"==typeof o.unref&&o.unref()}n.action="function"!=typeof e?function(t){return Promise.resolve(e)}:e,r.maxFailures&&t.error(D);var c=function(e){return function(t,r){return n[j].increment(e,r)}};function s(e){return function(t){var n=e[A]=setTimeout((function(){e[v]=g,e[w]=!0,e.emit("halfOpen",e.options.resetTimeout)}),e.options.resetTimeout);"function"==typeof n.unref&&n.unref()}}return n.on("success",c("successes")),n.on("failure",c("failures")),n.on("fallback",c("fallbacks")),n.on("timeout",c("timeouts")),n.on("fire",c("fires")),n.on("reject",c("rejects")),n.on("cacheHit",c("cacheHits")),n.on("cacheMiss",c("cacheMisses")),n.on("open",(function(e){return n[j].open()})),n.on("close",(function(e){return n[j].close()})),n.on("semaphoreLocked",c("semaphoreRejections")),n.on("open",s(l(n))),n.on("success",(function(e){n.halfOpen&&n.close()})),n.options.cache&&T.set(l(n),void 0),n}return n=f,o=[{key:"isOurError",value:function(e){return!!e[L]}}],(r=[{key:"close",value:function(){this[v]!==b&&(this[A]&&clearTimeout(this[A]),this[v]=b,this[w]=!1,this.emit("close"))}},{key:"open",value:function(){this[v]!==d&&(this[v]=d,this[w]=!1,this.emit("open"))}},{key:"shutdown",value:function(){this.disable(),this.removeAllListeners(),this[A]&&clearTimeout(this[A]),this[C]&&clearTimeout(this[C]),this.status.shutdown(),this[v]=O,this.emit("shutdown")}},{key:"isShutdown",get:function(){return this[v]===O}},{key:"name",get:function(){return this[x]}},{key:"group",get:function(){return this[S]}},{key:"pendingClose",get:function(){return this[w]}},{key:"closed",get:function(){return this[v]===b}},{key:"opened",get:function(){return this[v]===d}},{key:"halfOpen",get:function(){return this[v]===g}},{key:"status",get:function(){return this[j]}},{key:"stats",get:function(){return this[j].stats}},{key:"enabled",get:function(){return this[k]}},{key:"warmUp",get:function(){return this[P]}},{key:"volumeThreshold",get:function(){return this[_]}},{key:"fallback",value:function(e){var t=e;return e instanceof f&&(t=function(){return e.fire.apply(e,arguments)}),this[E]=t,this}},{key:"fire",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.call.apply(this,[this.action].concat(t))}},{key:"call",value:function(e){var t=this;if(this.isShutdown){var n=F("The circuit has been shutdown.","ESHUTDOWN");return Promise.reject(n)}for(var r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];var u,c=Array.prototype.slice.call(o);if(this.emit("fire",c),void 0!==T.get(this))return this.emit("cacheHit"),T.get(this);if(this.options.cache&&this.emit("cacheMiss"),!this[k]){var s=this.action.apply(e,c);return"function"==typeof s.then?s:Promise.resolve(s)}if(!this.closed&&!this.pendingClose){var a=F("Breaker is open","EOPENBREAKER");return this.emit("reject",a),q(this,a,c)||Promise.reject(a)}this[w]=!1;var f=!1;return new Promise((function(n,r){var o=Date.now();if(t.semaphore.test()){t.options.timeout&&(u=setTimeout((function(){f=!0;var e=F("Timed out after ".concat(t.options.timeout,"ms"),"ETIMEDOUT"),i=Date.now()-o;t.semaphore.release(),t.emit("timeout",e,i,c),R(e,t,u,c,i,n,r)}),t.options.timeout));try{var i=t.action.apply(e,c),s="function"==typeof i.then?i:Promise.resolve(i);s.then((function(e){f||(clearTimeout(u),t.emit("success",e,Date.now()-o),t.semaphore.release(),n(e),t.options.cache&&T.set(t,s))})).catch((function(e){if(!f){t.semaphore.release();var i=Date.now()-o;R(e,t,u,c,i,n,r)}}))}catch(e){t.semaphore.release();var a=Date.now()-o;R(e,t,u,c,a,n,r)}}else{var l=Date.now()-o,p=F("Semaphore locked","ESEMLOCKED");t.emit("semaphoreLocked",p,l),R(p,t,u,c,l,n,r)}}))}},{key:"clearCache",value:function(){T.set(this,void 0)}},{key:"healthCheck",value:function(e,t){var n=this;if(t=t||5e3,"function"!=typeof e)throw new TypeError("Health check function must be a function");if(isNaN(t))throw new TypeError("Health check interval must be a number");var r=function(t){e.apply(n).catch((function(e){n.emit("healthCheckFailed",e),n.open()}))},o=setInterval(r,t);"function"==typeof o.unref&&o.unref(),r()}},{key:"enable",value:function(){this[k]=!0}},{key:"disable",value:function(){this[k]=!1}}])&&c(n.prototype,r),o&&c(n,o),f}(h);function R(e,t,n,r,i,u,c){var s,a;if(clearTimeout(n),a=(s=t.options).errorFilter.apply(s,[e].concat(o(r))))t.emit("success",e,i),u(a);else{!function(e,t,n,r){if(e.emit("failure",t,r,n),e.warmUp)return;var o=e.stats;if(o.fires<e.volumeThreshold&&!e.halfOpen)return;(o.failures/o.fires*100>e.options.errorThresholdPercentage||o.failures>=e.options.maxFailures||e.halfOpen)&&e.open()}(t,e,r,i);var f=q(t,e,r);f?u(f):c(e)}}function q(e,t,n){if(e[E])try{var r=e[E].apply(e[E],[].concat(o(n),[t]));return e.emit("fallback",r,t),r instanceof Promise?r:Promise.resolve(r)}catch(e){return Promise.reject(e)}}function F(e,t){var n=new Error(e);return n.code=t,n[L]=!0,n}var N=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))};e.exports=M}).call(this,n(0))},function(e,t){var n,r,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function c(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{r="function"==typeof clearTimeout?clearTimeout:u}catch(e){r=u}}();var s,a=[],f=!1,l=-1;function p(){f&&s&&(f=!1,s.length?a=s.concat(a):l=-1,a.length&&h())}function h(){if(!f){var e=c(p);f=!0;for(var t=a.length;t;){for(s=a,a=[];++l<t;)s&&s[l].run();l=-1,t=a.length}s=null,f=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===u||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function y(e,t){this.fun=e,this.array=t}function m(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];a.push(new y(e,t)),1!==a.length||f||c(h)},y.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=m,o.addListener=m,o.once=m,o.off=m,o.removeListener=m,o.removeAllListeners=m,o.emit=m,o.prependListener=m,o.prependOnceListener=m,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t){e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},function(e,t,n){"use strict";(function(t){var r=n(10);
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.circuitBreaker=t():e.circuitBreaker=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=4)}([function(e,t,n){(function(t){var r=n(2),o=n(9);function i(){return(new Date).getTime()}var u,c=Array.prototype.slice,s={};u=void 0!==t&&t.console?t.console:"undefined"!=typeof window&&window.console?window.console:{};for(var a=[[function(){},"log"],[function(){u.log.apply(u,arguments)},"info"],[function(){u.log.apply(u,arguments)},"warn"],[function(){u.warn.apply(u,arguments)},"error"],[function(e){s[e]=i()},"time"],[function(e){var t=s[e];if(!t)throw new Error("No such label: "+e);delete s[e];var n=i()-t;u.log(e+": "+n+"ms")},"timeEnd"],[function(){var e=new Error;e.name="Trace",e.message=r.format.apply(null,arguments),u.error(e.stack)},"trace"],[function(e){u.log(r.inspect(e)+"\n")},"dir"],[function(e){if(!e){var t=c.call(arguments,1);o.ok(!1,r.format.apply(null,t))}},"assert"]],f=0;f<a.length;f++){var l=a[f],p=l[0],h=l[1];u[h]||(u[h]=p)}e.exports=u}).call(this,n(1))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){(function(e,r){var o=Object.getOwnPropertyDescriptors||function(e){for(var t=Object.keys(e),n={},r=0;r<t.length;r++)n[t[r]]=Object.getOwnPropertyDescriptor(e,t[r]);return n},i=/%[sdj%]/g;t.format=function(e){if(!b(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(s(arguments[n]));return t.join(" ")}n=1;for(var r=arguments,o=r.length,u=String(e).replace(i,(function(e){if("%%"===e)return"%";if(n>=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),c=r[n];n<o;c=r[++n])v(c)||!O(c)?u+=" "+c:u+=" "+s(c);return u},t.deprecate=function(n,o){if(void 0!==e&&!0===e.noDeprecation)return n;if(void 0===e)return function(){return t.deprecate(n,o).apply(this,arguments)};var i=!1;return function(){if(!i){if(e.throwDeprecation)throw new Error(o);e.traceDeprecation?r.trace(o):r.error(o),i=!0}return n.apply(this,arguments)}};var u,c={};function s(e,n){var r={seen:[],stylize:f};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),m(n)?r.showHidden=n:n&&t._extend(r,n),g(r.showHidden)&&(r.showHidden=!1),g(r.depth)&&(r.depth=2),g(r.colors)&&(r.colors=!1),g(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=a),l(r,e,r.depth)}function a(e,t){var n=s.styles[t];return n?"["+s.colors[n][0]+"m"+e+"["+s.colors[n][1]+"m":e}function f(e,t){return e}function l(e,n,r){if(e.customInspect&&n&&x(n.inspect)&&n.inspect!==t.inspect&&(!n.constructor||n.constructor.prototype!==n)){var o=n.inspect(r,e);return b(o)||(o=l(e,o,r)),o}var i=function(e,t){if(g(t))return e.stylize("undefined","undefined");if(b(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}if(d(t))return e.stylize(""+t,"number");if(m(t))return e.stylize(""+t,"boolean");if(v(t))return e.stylize("null","null")}(e,n);if(i)return i;var u=Object.keys(n),c=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(u);if(e.showHidden&&(u=Object.getOwnPropertyNames(n)),j(n)&&(u.indexOf("message")>=0||u.indexOf("description")>=0))return p(n);if(0===u.length){if(x(n)){var s=n.name?": "+n.name:"";return e.stylize("[Function"+s+"]","special")}if(w(n))return e.stylize(RegExp.prototype.toString.call(n),"regexp");if(E(n))return e.stylize(Date.prototype.toString.call(n),"date");if(j(n))return p(n)}var a,f="",O=!1,S=["{","}"];(y(n)&&(O=!0,S=["[","]"]),x(n))&&(f=" [Function"+(n.name?": "+n.name:"")+"]");return w(n)&&(f=" "+RegExp.prototype.toString.call(n)),E(n)&&(f=" "+Date.prototype.toUTCString.call(n)),j(n)&&(f=" "+p(n)),0!==u.length||O&&0!=n.length?r<0?w(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special"):(e.seen.push(n),a=O?function(e,t,n,r,o){for(var i=[],u=0,c=t.length;u<c;++u)_(t,String(u))?i.push(h(e,t,n,r,String(u),!0)):i.push("");return o.forEach((function(o){o.match(/^\d+$/)||i.push(h(e,t,n,r,o,!0))})),i}(e,n,r,c,u):u.map((function(t){return h(e,n,r,c,t,O)})),e.seen.pop(),function(e,t,n){if(e.reduce((function(e,t){return t.indexOf("\n")>=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1];return n[0]+t+" "+e.join(", ")+" "+n[1]}(a,f,S)):S[0]+f+S[1]}function p(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,n,r,o,i){var u,c,s;if((s=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]}).get?c=s.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):s.set&&(c=e.stylize("[Setter]","special")),_(r,o)||(u="["+o+"]"),c||(e.seen.indexOf(s.value)<0?(c=v(n)?l(e,s.value,null):l(e,s.value,n-1)).indexOf("\n")>-1&&(c=i?c.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+c.split("\n").map((function(e){return" "+e})).join("\n")):c=e.stylize("[Circular]","special")),g(u)){if(i&&o.match(/^\d+$/))return c;(u=JSON.stringify(""+o)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(u=u.substr(1,u.length-2),u=e.stylize(u,"name")):(u=u.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),u=e.stylize(u,"string"))}return u+": "+c}function y(e){return Array.isArray(e)}function m(e){return"boolean"==typeof e}function v(e){return null===e}function d(e){return"number"==typeof e}function b(e){return"string"==typeof e}function g(e){return void 0===e}function w(e){return O(e)&&"[object RegExp]"===S(e)}function O(e){return"object"==typeof e&&null!==e}function E(e){return O(e)&&"[object Date]"===S(e)}function j(e){return O(e)&&("[object Error]"===S(e)||e instanceof Error)}function x(e){return"function"==typeof e}function S(e){return Object.prototype.toString.call(e)}function T(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(n){if(g(u)&&(u=Object({WEB:"web"}).NODE_DEBUG||""),n=n.toUpperCase(),!c[n])if(new RegExp("\\b"+n+"\\b","i").test(u)){var o=e.pid;c[n]=function(){var e=t.format.apply(t,arguments);r.error("%s %d: %s",n,o,e)}}else c[n]=function(){};return c[n]},t.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=y,t.isBoolean=m,t.isNull=v,t.isNullOrUndefined=function(e){return null==e},t.isNumber=d,t.isString=b,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=g,t.isRegExp=w,t.isObject=O,t.isDate=E,t.isError=j,t.isFunction=x,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=n(7);var k=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function P(){var e=new Date,t=[T(e.getHours()),T(e.getMinutes()),T(e.getSeconds())].join(":");return[e.getDate(),k[e.getMonth()],t].join(" ")}function _(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){r.log("%s - %s",P(),t.format.apply(t,arguments))},t.inherits=n(8),t._extend=function(e,t){if(!t||!O(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e};var L="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function A(e,t){if(!e){var n=new Error("Promise was rejected with a falsy value");n.reason=e,e=n}return t(e)}t.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(L&&e[L]){var t;if("function"!=typeof(t=e[L]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,L,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,n,r=new Promise((function(e,r){t=e,n=r})),o=[],i=0;i<arguments.length;i++)o.push(arguments[i]);o.push((function(e,r){e?n(e):t(r)}));try{e.apply(this,o)}catch(e){n(e)}return r}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),L&&Object.defineProperty(t,L,{value:t,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(t,o(e))},t.promisify.custom=L,t.callbackify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');function n(){for(var n=[],r=0;r<arguments.length;r++)n.push(arguments[r]);var o=n.pop();if("function"!=typeof o)throw new TypeError("The last argument must be of type Function");var i=this,u=function(){return o.apply(i,arguments)};t.apply(this,n).then((function(t){e.nextTick(u,null,t)}),(function(t){e.nextTick(A,t,u)}))}return Object.setPrototypeOf(n,Object.getPrototypeOf(t)),Object.defineProperties(n,o(t)),n}}).call(this,n(6),n(0))},function(e,t,n){"use strict";(function(t){var n,r="object"==typeof Reflect?Reflect:null,o=r&&"function"==typeof r.apply?r.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)};n=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function u(){u.init.call(this)}e.exports=u,e.exports.once=function(e,t){return new Promise((function(n,r){function o(n){e.removeListener(t,i),r(n)}function i(){"function"==typeof e.removeListener&&e.removeListener("error",o),n([].slice.call(arguments))}v(e,t,i,{once:!0}),"error"!==t&&function(e,t,n){"function"==typeof e.on&&v(e,"error",t,n)}(e,o,{once:!0})}))},u.EventEmitter=u,u.prototype._events=void 0,u.prototype._eventsCount=0,u.prototype._maxListeners=void 0;var c=10;function s(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function a(e){return void 0===e._maxListeners?u.defaultMaxListeners:e._maxListeners}function f(e,n,r,o){var i,u,c,f;if(s(r),void 0===(u=e._events)?(u=e._events=Object.create(null),e._eventsCount=0):(void 0!==u.newListener&&(e.emit("newListener",n,r.listener?r.listener:r),u=e._events),c=u[n]),void 0===c)c=u[n]=r,++e._eventsCount;else if("function"==typeof c?c=u[n]=o?[r,c]:[c,r]:o?c.unshift(r):c.push(r),(i=a(e))>0&&c.length>i&&!c.warned){c.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+c.length+" "+String(n)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=e,l.type=n,l.count=c.length,f=l,t&&t.warn&&t.warn(f)}return e}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=l.bind(r);return o.listener=n,r.wrapFn=o,o}function h(e,t,n){var r=e._events;if(void 0===r)return[];var o=r[t];return void 0===o?[]:"function"==typeof o?n?[o.listener||o]:[o]:n?function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(o):m(o,o.length)}function y(e){var t=this._events;if(void 0!==t){var n=t[e];if("function"==typeof n)return 1;if(void 0!==n)return n.length}return 0}function m(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}function v(e,t,n,r){if("function"==typeof e.on)r.once?e.once(t,n):e.on(t,n);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,(function o(i){r.once&&e.removeEventListener(t,o),n(i)}))}}Object.defineProperty(u,"defaultMaxListeners",{enumerable:!0,get:function(){return c},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");c=e}}),u.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},u.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},u.prototype.getMaxListeners=function(){return a(this)},u.prototype.emit=function(e){for(var t=[],n=1;n<arguments.length;n++)t.push(arguments[n]);var r="error"===e,i=this._events;if(void 0!==i)r=r&&void 0===i.error;else if(!r)return!1;if(r){var u;if(t.length>0&&(u=t[0]),u instanceof Error)throw u;var c=new Error("Unhandled error."+(u?" ("+u.message+")":""));throw c.context=u,c}var s=i[e];if(void 0===s)return!1;if("function"==typeof s)o(s,this,t);else{var a=s.length,f=m(s,a);for(n=0;n<a;++n)o(f[n],this,t)}return!0},u.prototype.addListener=function(e,t){return f(this,e,t,!1)},u.prototype.on=u.prototype.addListener,u.prototype.prependListener=function(e,t){return f(this,e,t,!0)},u.prototype.once=function(e,t){return s(t),this.on(e,p(this,e,t)),this},u.prototype.prependOnceListener=function(e,t){return s(t),this.prependListener(e,p(this,e,t)),this},u.prototype.removeListener=function(e,t){var n,r,o,i,u;if(s(t),void 0===(r=this._events))return this;if(void 0===(n=r[e]))return this;if(n===t||n.listener===t)0==--this._eventsCount?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(o=-1,i=n.length-1;i>=0;i--)if(n[i]===t||n[i].listener===t){u=n[i].listener,o=i;break}if(o<0)return this;0===o?n.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(n,o),1===n.length&&(r[e]=n[0]),void 0!==r.removeListener&&this.emit("removeListener",e,u||t)}return this},u.prototype.off=u.prototype.removeListener,u.prototype.removeAllListeners=function(e){var t,n,r;if(void 0===(n=this._events))return this;if(void 0===n.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==n[e]&&(0==--this._eventsCount?this._events=Object.create(null):delete n[e]),this;if(0===arguments.length){var o,i=Object.keys(n);for(r=0;r<i.length;++r)"removeListener"!==(o=i[r])&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(void 0!==t)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this},u.prototype.listeners=function(e){return h(this,e,!0)},u.prototype.rawListeners=function(e){return h(this,e,!1)},u.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):y.call(e,t)},u.prototype.listenerCount=y,u.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}}).call(this,n(0))},function(e,t,n){"use strict";e.exports=n(5)},function(e,t,n){"use strict";(function(t){function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function o(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return i(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function c(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=p(e);if(t){var o=p(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return f(this,n)}}function f(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?l(e):t}function l(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var h=n(3),y=n(11),m=n(12),v=Symbol("state"),d=Symbol("open"),b=Symbol("closed"),g=Symbol("half-open"),w=Symbol("pending-close"),O=Symbol("shutdown"),E=Symbol("fallback"),j=Symbol("status"),x=Symbol("name"),S=Symbol("group"),T=new WeakMap,k=Symbol("Enabled"),P=Symbol("warming-up"),_=Symbol("volume-threshold"),L=Symbol("our-error"),A=Symbol("reset-timeout"),C=Symbol("warmup-timeout"),D="options.maxFailures is deprecated. Please use options.errorThresholdPercentage",M=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(f,e);var n,r,o,i=a(f);function f(e){var n,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(u(this,f),(n=i.call(this)).options=r,n.options.timeout=!1!==r.timeout&&(r.timeout||1e4),n.options.resetTimeout=r.resetTimeout||3e4,n.options.errorThresholdPercentage=r.errorThresholdPercentage||50,n.options.rollingCountTimeout=r.rollingCountTimeout||1e4,n.options.rollingCountBuckets=r.rollingCountBuckets||10,n.options.rollingPercentilesEnabled=!1!==r.rollingPercentilesEnabled,n.options.capacity=Number.isInteger(r.capacity)?r.capacity:Number.MAX_SAFE_INTEGER,n.options.errorFilter=r.errorFilter||function(e){return!1},n.semaphore=new m(n.options.capacity),!e)throw new TypeError("No action provided. Cannot construct a CircuitBreaker without an invocable action.");if(n[_]=Number.isInteger(r.volumeThreshold)?r.volumeThreshold:0,n[P]=!0===r.allowWarmUp,n[j]=new y(n.options),n[v]=b,n[E]=null,n[w]=!1,n[x]=r.name||e.name||N(),n[S]=r.group||n[x],n[k]=!1!==r.enabled,n[P]){var o=n[C]=setTimeout((function(e){return n[P]=!1}),n.options.rollingCountTimeout);"function"==typeof o.unref&&o.unref()}n.action="function"!=typeof e?function(t){return Promise.resolve(e)}:e,r.maxFailures&&t.error(D);var c=function(e){return function(t,r){return n[j].increment(e,r)}};function s(e){return function(t){var n=e[A]=setTimeout((function(){e[v]=g,e[w]=!0,e.emit("halfOpen",e.options.resetTimeout)}),e.options.resetTimeout);"function"==typeof n.unref&&n.unref()}}return n.on("success",c("successes")),n.on("failure",c("failures")),n.on("fallback",c("fallbacks")),n.on("timeout",c("timeouts")),n.on("fire",c("fires")),n.on("reject",c("rejects")),n.on("cacheHit",c("cacheHits")),n.on("cacheMiss",c("cacheMisses")),n.on("open",(function(e){return n[j].open()})),n.on("close",(function(e){return n[j].close()})),n.on("semaphoreLocked",c("semaphoreRejections")),n.on("open",s(l(n))),n.on("success",(function(e){n.halfOpen&&n.close()})),n.options.cache&&T.set(l(n),void 0),n}return n=f,o=[{key:"isOurError",value:function(e){return!!e[L]}}],(r=[{key:"close",value:function(){this[v]!==b&&(this[A]&&clearTimeout(this[A]),this[v]=b,this[w]=!1,this.emit("close"))}},{key:"open",value:function(){this[v]!==d&&(this[v]=d,this[w]=!1,this.emit("open"))}},{key:"shutdown",value:function(){this.disable(),this.removeAllListeners(),this[A]&&clearTimeout(this[A]),this[C]&&clearTimeout(this[C]),this.status.shutdown(),this[v]=O,this.emit("shutdown")}},{key:"isShutdown",get:function(){return this[v]===O}},{key:"name",get:function(){return this[x]}},{key:"group",get:function(){return this[S]}},{key:"pendingClose",get:function(){return this[w]}},{key:"closed",get:function(){return this[v]===b}},{key:"opened",get:function(){return this[v]===d}},{key:"halfOpen",get:function(){return this[v]===g}},{key:"status",get:function(){return this[j]}},{key:"stats",get:function(){return this[j].stats}},{key:"enabled",get:function(){return this[k]}},{key:"warmUp",get:function(){return this[P]}},{key:"volumeThreshold",get:function(){return this[_]}},{key:"fallback",value:function(e){var t=e;return e instanceof f&&(t=function(){return e.fire.apply(e,arguments)}),this[E]=t,this}},{key:"fire",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.call.apply(this,[this.action].concat(t))}},{key:"call",value:function(e){var t=this;if(this.isShutdown){var n=F("The circuit has been shutdown.","ESHUTDOWN");return Promise.reject(n)}for(var r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];var u,c=Array.prototype.slice.call(o);if(this.emit("fire",c),void 0!==T.get(this))return this.emit("cacheHit"),T.get(this);if(this.options.cache&&this.emit("cacheMiss"),!this[k]){var s=this.action.apply(e,c);return"function"==typeof s.then?s:Promise.resolve(s)}if(!this.closed&&!this.pendingClose){var a=F("Breaker is open","EOPENBREAKER");return this.emit("reject",a),q(this,a,c)||Promise.reject(a)}this[w]=!1;var f=!1;return new Promise((function(n,r){var o=Date.now();if(t.semaphore.test()){t.options.timeout&&(u=setTimeout((function(){f=!0;var e=F("Timed out after ".concat(t.options.timeout,"ms"),"ETIMEDOUT"),i=Date.now()-o;t.semaphore.release(),t.emit("timeout",e,i,c),R(e,t,u,c,i,n,r)}),t.options.timeout));try{var i=t.action.apply(e,c),s="function"==typeof i.then?i:Promise.resolve(i);s.then((function(e){f||(clearTimeout(u),t.emit("success",e,Date.now()-o),t.semaphore.release(),n(e),t.options.cache&&T.set(t,s))})).catch((function(e){if(!f){t.semaphore.release();var i=Date.now()-o;R(e,t,u,c,i,n,r)}}))}catch(e){t.semaphore.release();var a=Date.now()-o;R(e,t,u,c,a,n,r)}}else{var l=Date.now()-o,p=F("Semaphore locked","ESEMLOCKED");t.emit("semaphoreLocked",p,l),R(p,t,u,c,l,n,r)}}))}},{key:"clearCache",value:function(){T.set(this,void 0)}},{key:"healthCheck",value:function(e,t){var n=this;if(t=t||5e3,"function"!=typeof e)throw new TypeError("Health check function must be a function");if(isNaN(t))throw new TypeError("Health check interval must be a number");var r=function(t){e.apply(n).catch((function(e){n.emit("healthCheckFailed",e),n.open()}))},o=setInterval(r,t);"function"==typeof o.unref&&o.unref(),r()}},{key:"enable",value:function(){this[k]=!0}},{key:"disable",value:function(){this[k]=!1}}])&&c(n.prototype,r),o&&c(n,o),f}(h);function R(e,t,n,r,i,u,c){var s;if(clearTimeout(n),(s=t.options).errorFilter.apply(s,[e].concat(o(r))))t.emit("success",e,i);else{!function(e,t,n,r){if(e.emit("failure",t,r,n),e.warmUp)return;var o=e.stats;if(o.fires<e.volumeThreshold&&!e.halfOpen)return;(o.failures/o.fires*100>e.options.errorThresholdPercentage||o.failures>=e.options.maxFailures||e.halfOpen)&&e.open()}(t,e,r,i);var a=q(t,e,r);if(a)return u(a)}c(e)}function q(e,t,n){if(e[E])try{var r=e[E].apply(e[E],[].concat(o(n),[t]));return e.emit("fallback",r,t),r instanceof Promise?r:Promise.resolve(r)}catch(e){return Promise.reject(e)}}function F(e,t){var n=new Error(e);return n.code=t,n[L]=!0,n}var N=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))};e.exports=M}).call(this,n(0))},function(e,t){var n,r,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function c(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{r="function"==typeof clearTimeout?clearTimeout:u}catch(e){r=u}}();var s,a=[],f=!1,l=-1;function p(){f&&s&&(f=!1,s.length?a=s.concat(a):l=-1,a.length&&h())}function h(){if(!f){var e=c(p);f=!0;for(var t=a.length;t;){for(s=a,a=[];++l<t;)s&&s[l].run();l=-1,t=a.length}s=null,f=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===u||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function y(e,t){this.fun=e,this.array=t}function m(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];a.push(new y(e,t)),1!==a.length||f||c(h)},y.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=m,o.addListener=m,o.once=m,o.off=m,o.removeListener=m,o.removeAllListeners=m,o.emit=m,o.prependListener=m,o.prependOnceListener=m,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t){e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},function(e,t,n){"use strict";(function(t){var r=n(10);
/*!

@@ -3,0 +3,0 @@ * The buffer module from node.js, for the browser.

@@ -55,3 +55,3 @@ 'use strict';

* If they are disabled, all summary statistics (mean, percentiles) are
* returned as -1. Default: false
* returned as -1. Default: true
* @param {Number} options.capacity the number of concurrent requests allowed.

@@ -659,14 +659,16 @@ * If the number currently executing function calls is equal to

let errorFiltered;
if ((errorFiltered = circuit.options.errorFilter(error, ...args))) {
if (circuit.options.errorFilter(error, ...args)) {
// The error was filtered, so emit 'success'
circuit.emit('success', error, latency);
resolve(errorFiltered);
} else {
// Error was not filtered, so emit 'failure'
fail(circuit, error, args, latency);
// Only call the fallback function if there errorFilter doesn't succeed
// Only call the fallback function if errorFilter doesn't succeed
// If the fallback function succeeds, resolve
const fb = fallback(circuit, error, args);
if (fb) resolve(fb);
else reject(error);
if (fb) return resolve(fb);
}
// In all other cases, reject
reject(error);
}

@@ -673,0 +675,0 @@

{
"name": "opossum",
"version": "6.0.0",
"version": "6.0.1",
"author": "Red Hat, Inc.",

@@ -21,3 +21,4 @@ "license": "Apache-2.0",

"lint": "standardx test/*.js index.js lib/*.js test/*/*.js",
"clean": "rm -rf node_modules dist/*.js test/browser/webpack-test.js"
"clean": "rm -rf node_modules dist/*.js test/browser/webpack-test.js",
"prepublishOnly": "npm run build"
},

@@ -24,0 +25,0 @@ "standard-version": {

@@ -246,2 +246,55 @@ # opossum

### Calculating errorThresholdPercentage
The `errorThresholdPercentage` value is compared to the error rate. That rate is determined by dividing the number of failures by the number of times the circuit has been fired. You can see this comparison here:
```js
// check stats to see if the circuit should be opened
const stats = circuit.stats;
if ((stats.fires < circuit.volumeThreshold) && !circuit.halfOpen) return;
const errorRate = stats.failures / stats.fires * 100;
if (errorRate > circuit.options.errorThresholdPercentage ||
stats.failures >= circuit.options.maxFailures ||
circuit.halfOpen) {
circuit.open();
}
```
The numbers for `fires` and `failures` come from the stats that are indeed governed by `rollingCountTimeout` and `rollingCountBuckets`. The timeout value is the total number of seconds for which the stats are being maintained, and the buckets value is the number of slots in the window. The defaults are 10 seconds and 10 buckets. So, the statistics that are being compared against `errorThresholdPercentage` are based on 10 samples, one per second over the last 10 seconds.
Example: a circuit is fired 24 times over 10 seconds with a somewhat bursty pattern, failing three times.
```
| fires: 2 | fires: 1 | fires: 3 | fires: 0 | fires: 9 | fires: 3 | fires: 2 | fires: 0 | fires: 8 | fires: 0 |
| fails: 0 | fails: 0 | fails: 0 | fails: 0 | fails: 0 | fails: 3 | fails: 0 | fails: 0 | fails: 0 | fails: 0 |
```
The failure rate here is 3/24 or 1/8 or 12.5%. The default error threshold is 50%, so in this case, the circuit would not open. However, if you modified the `rollingCountTimeout` to 3 seconds, and the `rollingCountBuckets` to 3 (not recommended), then the stats array might look like these three seconds from above.
```
| fires: 3 | fires: 2 | fires: 0 |
| fails: 3 | fails: 0 | fails: 0 |
```
Now, without changing `errorThresholdPercentage` our circuit will open because our error rate is now 3/5 or 60%. It's tricky to test this stuff because the array of statistics is a rolling count. Every second the oldest bucket is removed and a new one is added, so the totals change constantly in a way that may not be intuitive.
For example, if the first example is shifted right, dropping the first bucket and adding another with `fires: 3` the total number of `fires` now in the stats is not 27 (24+3) but 25 (24-2+3).
The code that is summing the stats samples is here:
```js
const totals = this[WINDOW].reduce((acc, val) => {
if (!val) { return acc; }
Object.keys(acc).forEach(key => {
if (key !== 'latencyTimes' && key !== 'percentiles') {
(acc[key] += val[key] || 0);
}
});
if (this.rollingPercentilesEnabled) {
acc.latencyTimes.push.apply(acc.latencyTimes, val.latencyTimes || []);
}
return acc;
}, bucket());
```
### Typings

@@ -248,0 +301,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc