Comparing version 4.2.2 to 4.2.3-0
@@ -5,2 +5,4 @@ # Changelog | ||
### [4.2.3-0](https://github.com/nodeshift/opossum/compare/v4.2.2...v4.2.3-0) (2020-01-03) | ||
### [4.2.2](https://github.com/nodeshift/opossum/compare/v4.2.1...v4.2.2) (2020-01-02) | ||
@@ -7,0 +9,0 @@ |
@@ -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,o=n(2),i=n(8),u=n(10),s=Array.prototype.slice,c={};r=void 0!==t&&t.console?t.console:"undefined"!=typeof window&&window.console?window.console:{};for(var a=[[function(){},"log"],[function(){r.log.apply(r,arguments)},"info"],[function(){r.log.apply(r,arguments)},"warn"],[function(){r.warn.apply(r,arguments)},"error"],[function(e){c[e]=u()},"time"],[function(e){var t=c[e];if(!t)throw new Error("No such label: "+e);var n=u()-t;r.log(e+": "+n+"ms")},"timeEnd"],[function(){var e=new Error;e.name="Trace",e.message=o.format.apply(null,arguments),r.error(e.stack)},"trace"],[function(e){r.log(o.inspect(e)+"\n")},"dir"],[function(e){if(!e){var t=s.call(arguments,1);i.ok(!1,o.format.apply(null,t))}},"assert"]],f=0;f<a.length;f++){var l=a[f],p=l[0],h=l[1];r[h]||(r[h]=p)}e.exports=r}).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(!d(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(c(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}})),s=r[n];n<o;s=r[++n])v(s)||!O(s)?u+=" "+s:u+=" "+c(s);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,s={};function c(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),b(r.showHidden)&&(r.showHidden=!1),b(r.depth)&&(r.depth=2),b(r.colors)&&(r.colors=!1),b(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=a),l(r,e,r.depth)}function a(e,t){var n=c.styles[t];return n?"["+c.colors[n][0]+"m"+e+"["+c.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 d(o)||(o=l(e,o,r)),o}var i=function(e,t){if(b(t))return e.stylize("undefined","undefined");if(d(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}if(g(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),s=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 c=n.name?": "+n.name:"";return e.stylize("[Function"+c+"]","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,T=["{","}"];(y(n)&&(O=!0,T=["[","]"]),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,s=t.length;u<s;++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,s,u):u.map((function(t){return h(e,n,r,s,t,O)})),e.seen.pop(),function(e,t,n){if(e.reduce((function(e,t){return 0,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,T)):T[0]+f+T[1]}function p(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,n,r,o,i){var u,s,c;if((c=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]}).get?s=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(s=e.stylize("[Setter]","special")),_(r,o)||(u="["+o+"]"),s||(e.seen.indexOf(c.value)<0?(s=v(n)?l(e,c.value,null):l(e,c.value,n-1)).indexOf("\n")>-1&&(s=i?s.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+s.split("\n").map((function(e){return" "+e})).join("\n")):s=e.stylize("[Circular]","special")),b(u)){if(i&&o.match(/^\d+$/))return s;(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+": "+s}function y(e){return Array.isArray(e)}function m(e){return"boolean"==typeof e}function v(e){return null===e}function g(e){return"number"==typeof e}function d(e){return"string"==typeof e}function b(e){return void 0===e}function w(e){return O(e)&&"[object RegExp]"===T(e)}function O(e){return"object"==typeof e&&null!==e}function E(e){return O(e)&&"[object Date]"===T(e)}function j(e){return O(e)&&("[object Error]"===T(e)||e instanceof Error)}function x(e){return"function"==typeof e}function T(e){return Object.prototype.toString.call(e)}function S(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(n){if(b(u)&&(u=Object({WEB:"web"}).NODE_DEBUG||""),n=n.toUpperCase(),!s[n])if(new RegExp("\\b"+n+"\\b","i").test(u)){var o=e.pid;s[n]=function(){var e=t.format.apply(t,arguments);r.error("%s %d: %s",n,o,e)}}else s[n]=function(){};return s[n]},t.inspect=c,c.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]},c.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=g,t.isString=d,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=b,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(6);var k=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function P(){var e=new Date,t=[S(e.getHours()),S(e.getMinutes()),S(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(7),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(5),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,u.EventEmitter=u,u.prototype._events=void 0,u.prototype._eventsCount=0,u.prototype._maxListeners=void 0;var s=10;function c(e){return void 0===e._maxListeners?u.defaultMaxListeners:e._maxListeners}function a(e,n,r,o){var i,u,s,a;if("function"!=typeof r)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r);if(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),s=u[n]),void 0===s)s=u[n]=r,++e._eventsCount;else if("function"==typeof s?s=u[n]=o?[r,s]:[s,r]:o?s.unshift(r):s.push(r),(i=c(e))>0&&s.length>i&&!s.warned){s.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(n)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=e,f.type=n,f.count=s.length,a=f,t&&t.warn&&t.warn(a)}return e}function f(){for(var e=[],t=0;t<arguments.length;t++)e.push(arguments[t]);this.fired||(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,o(this.listener,this.target,e))}function l(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=f.bind(r);return o.listener=n,r.wrapFn=o,o}function p(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):y(o,o.length)}function h(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 y(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}Object.defineProperty(u,"defaultMaxListeners",{enumerable:!0,get:function(){return s},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+".");s=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 c(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 s=new Error("Unhandled error."+(u?" ("+u.message+")":""));throw s.context=u,s}var c=i[e];if(void 0===c)return!1;if("function"==typeof c)o(c,this,t);else{var a=c.length,f=y(c,a);for(n=0;n<a;++n)o(f[n],this,t)}return!0},u.prototype.addListener=function(e,t){return a(this,e,t,!1)},u.prototype.on=u.prototype.addListener,u.prototype.prependListener=function(e,t){return a(this,e,t,!0)},u.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.on(e,l(this,e,t)),this},u.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.prependListener(e,l(this,e,t)),this},u.prototype.removeListener=function(e,t){var n,r,o,i,u;if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);if(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 p(this,e,!0)},u.prototype.rawListeners=function(e){return p(this,e,!1)},u.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},u.prototype.listenerCount=h,u.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}}).call(this,n(0))},function(e,t,n){"use strict";(function(t){function r(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function o(e){return(o="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 i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(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 c(e,t,n){return t&&s(e.prototype,t),n&&s(e,n),e}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var f=n(3),l=n(11),p=n(12),h=Symbol("state"),y=Symbol("open"),m=Symbol("closed"),v=Symbol("half-open"),g=Symbol("pending-close"),d=Symbol("shutdown"),b=Symbol("fallback"),w=Symbol("status"),O=Symbol("name"),E=Symbol("group"),j=new WeakMap,x=Symbol("Enabled"),T=Symbol("warming-up"),S=Symbol("volume-threshold"),k=Symbol("our-error"),P=Symbol("reset-timeout"),_=Symbol("warmup-timeout"),L="options.maxFailures is deprecated. Please use options.errorThresholdPercentage",A=function(e){function n(e){var r,s,c,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),s=this,c=i(n).call(this),(r=!c||"object"!==o(c)&&"function"!=typeof c?u(s):c).options=a,r.options.timeout=a.timeout||1e4,r.options.resetTimeout=a.resetTimeout||3e4,r.options.errorThresholdPercentage=a.errorThresholdPercentage||50,r.options.rollingCountTimeout=a.rollingCountTimeout||1e4,r.options.rollingCountBuckets=a.rollingCountBuckets||10,r.options.rollingPercentilesEnabled=!1!==a.rollingPercentilesEnabled,r.options.capacity=Number.isInteger(a.capacity)?a.capacity:Number.MAX_SAFE_INTEGER,r.options.errorFilter=a.errorFilter||function(e){return!1},r.semaphore=new p(r.options.capacity),r[S]=Number.isInteger(a.volumeThreshold)?a.volumeThreshold:0,r[T]=!0===a.allowWarmUp,r[w]=new l(r.options),r[h]=m,r[b]=null,r[g]=!1,r[O]=a.name||e.name||F(),r[E]=a.group||r[O],r[x]=!1!==a.enabled,r[T]){var f=r[_]=setTimeout((function(e){return r[T]=!1}),r.options.rollingCountTimeout);"function"==typeof f.unref&&f.unref()}r.action="function"!=typeof e?function(t){return Promise.resolve(e)}:e,a.maxFailures&&t.error(L);var y,d=function(e){return function(t,n){return r[w].increment(e,n)}};return r.on("success",d("successes")),r.on("failure",d("failures")),r.on("fallback",d("fallbacks")),r.on("timeout",d("timeouts")),r.on("fire",d("fires")),r.on("reject",d("rejects")),r.on("cacheHit",d("cacheHits")),r.on("cacheMiss",d("cacheMisses")),r.on("open",(function(e){return r[w].open()})),r.on("close",(function(e){return r[w].close()})),r.on("semaphoreLocked",d("semaphoreRejections")),r.on("open",(y=u(r),function(e){var t=y[P]=setTimeout((function(){y[h]=v,y[g]=!0,y.emit("halfOpen",y.options.resetTimeout)}),y.options.resetTimeout);"function"==typeof t.unref&&t.unref()})),r.on("success",(function(e){r.halfOpen&&r.close()})),r.options.cache&&j.set(u(r),void 0),r}return 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&&a(e,t)}(n,e),c(n,null,[{key:"isOurError",value:function(e){return!!e[k]}}]),c(n,[{key:"close",value:function(){this[h]!==m&&(this[P]&&clearTimeout(this[P]),this[h]=m,this[g]=!1,this.emit("close"))}},{key:"open",value:function(){this[h]!==y&&(this[h]=y,this[g]=!1,this.emit("open"))}},{key:"shutdown",value:function(){this.disable(),this.removeAllListeners(),this[P]&&clearTimeout(this[P]),this[_]&&clearTimeout(this[_]),this.status.shutdown(),this[h]=d,this.emit("shutdown")}},{key:"fallback",value:function(e){var t=e;return e instanceof n&&(t=function(){return e.fire.apply(e,arguments)}),this[b]=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=M("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,s=Array.prototype.slice.call(o);if(this.emit("fire",s),void 0!==j.get(this))return this.emit("cacheHit"),j.get(this);if(this.options.cache&&this.emit("cacheMiss"),!this[x]){var c=this.action.apply(e,s);return"function"==typeof c.then?c:Promise.resolve(c)}if(!this.closed&&!this.pendingClose){var a=M("Breaker is open","EOPENBREAKER");return this.emit("reject",a),D(this,a,s)||Promise.reject(a)}this[g]=!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=M("Timed out after ".concat(t.options.timeout,"ms"),"ETIMEDOUT"),i=Date.now()-o;t.semaphore.release(),t.emit("timeout",e,i,s),C(e,t,u,s,i,n,r)}),t.options.timeout));try{var i=t.action.apply(e,s),c="function"==typeof i.then?i:Promise.resolve(i);c.then((function(e){f||(clearTimeout(u),t.emit("success",e,Date.now()-o),t.semaphore.release(),n(e),t.options.cache&&j.set(t,c))})).catch((function(e){if(!f){t.semaphore.release();var i=Date.now()-o;C(e,t,u,s,i,n,r)}}))}catch(e){t.semaphore.release();var a=Date.now()-o;C(e,t,u,s,a,n,r)}}else{var l=Date.now()-o,p=M("Semaphore locked","ESEMLOCKED");t.emit("semaphoreLocked",p,l),C(p,t,u,s,l,n,r)}}))}},{key:"clearCache",value:function(){j.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[x]=!0}},{key:"disable",value:function(){this[x]=!1}},{key:"isShutdown",get:function(){return this[h]===d}},{key:"name",get:function(){return this[O]}},{key:"group",get:function(){return this[E]}},{key:"pendingClose",get:function(){return this[g]}},{key:"closed",get:function(){return this[h]===m}},{key:"opened",get:function(){return this[h]===y}},{key:"halfOpen",get:function(){return this[h]===v}},{key:"status",get:function(){return this[w]}},{key:"stats",get:function(){return this[w].stats}},{key:"enabled",get:function(){return this[x]}},{key:"warmUp",get:function(){return this[T]}},{key:"volumeThreshold",get:function(){return this[S]}}]),n}(f);function C(e,t,n,r,o,i,u){clearTimeout(n),t.options.errorFilter(e)?t.emit("success",e,o):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,o);var s=D(t,e,r);s?i(s):u(e)}function D(e,t,n){if(e[b]){var o=e[b].apply(e[b],[].concat(r(n),[t]));return e.emit("fallback",o,t),o instanceof Promise?o:Promise.resolve(o)}}function M(e,t){var n=new Error(e);return n.code=t,n[k]=!0,n}var F=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=A}).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 s(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 c,a=[],f=!1,l=-1;function p(){f&&c&&(f=!1,c.length?a=c.concat(a):l=-1,a.length&&h())}function h(){if(!f){var e=s(p);f=!0;for(var t=a.length;t;){for(c=a,a=[];++l<t;)c&&c[l].run();l=-1,t=a.length}c=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||s(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(9); | ||
!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,o=n(2),i=n(9),u=n(11),s=Array.prototype.slice,c={};r=void 0!==t&&t.console?t.console:"undefined"!=typeof window&&window.console?window.console:{};for(var a=[[function(){},"log"],[function(){r.log.apply(r,arguments)},"info"],[function(){r.log.apply(r,arguments)},"warn"],[function(){r.warn.apply(r,arguments)},"error"],[function(e){c[e]=u()},"time"],[function(e){var t=c[e];if(!t)throw new Error("No such label: "+e);var n=u()-t;r.log(e+": "+n+"ms")},"timeEnd"],[function(){var e=new Error;e.name="Trace",e.message=o.format.apply(null,arguments),r.error(e.stack)},"trace"],[function(e){r.log(o.inspect(e)+"\n")},"dir"],[function(e){if(!e){var t=s.call(arguments,1);i.ok(!1,o.format.apply(null,t))}},"assert"]],f=0;f<a.length;f++){var l=a[f],p=l[0],h=l[1];r[h]||(r[h]=p)}e.exports=r}).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(!d(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(c(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}})),s=r[n];n<o;s=r[++n])v(s)||!O(s)?u+=" "+s:u+=" "+c(s);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,s={};function c(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),b(r.showHidden)&&(r.showHidden=!1),b(r.depth)&&(r.depth=2),b(r.colors)&&(r.colors=!1),b(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=a),l(r,e,r.depth)}function a(e,t){var n=c.styles[t];return n?"["+c.colors[n][0]+"m"+e+"["+c.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 d(o)||(o=l(e,o,r)),o}var i=function(e,t){if(b(t))return e.stylize("undefined","undefined");if(d(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}if(g(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),s=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 c=n.name?": "+n.name:"";return e.stylize("[Function"+c+"]","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,T=["{","}"];(y(n)&&(O=!0,T=["[","]"]),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,s=t.length;u<s;++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,s,u):u.map((function(t){return h(e,n,r,s,t,O)})),e.seen.pop(),function(e,t,n){if(e.reduce((function(e,t){return 0,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,T)):T[0]+f+T[1]}function p(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,n,r,o,i){var u,s,c;if((c=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]}).get?s=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(s=e.stylize("[Setter]","special")),_(r,o)||(u="["+o+"]"),s||(e.seen.indexOf(c.value)<0?(s=v(n)?l(e,c.value,null):l(e,c.value,n-1)).indexOf("\n")>-1&&(s=i?s.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+s.split("\n").map((function(e){return" "+e})).join("\n")):s=e.stylize("[Circular]","special")),b(u)){if(i&&o.match(/^\d+$/))return s;(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+": "+s}function y(e){return Array.isArray(e)}function m(e){return"boolean"==typeof e}function v(e){return null===e}function g(e){return"number"==typeof e}function d(e){return"string"==typeof e}function b(e){return void 0===e}function w(e){return O(e)&&"[object RegExp]"===T(e)}function O(e){return"object"==typeof e&&null!==e}function E(e){return O(e)&&"[object Date]"===T(e)}function j(e){return O(e)&&("[object Error]"===T(e)||e instanceof Error)}function x(e){return"function"==typeof e}function T(e){return Object.prototype.toString.call(e)}function S(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(n){if(b(u)&&(u=Object({WEB:"web"}).NODE_DEBUG||""),n=n.toUpperCase(),!s[n])if(new RegExp("\\b"+n+"\\b","i").test(u)){var o=e.pid;s[n]=function(){var e=t.format.apply(t,arguments);r.error("%s %d: %s",n,o,e)}}else s[n]=function(){};return s[n]},t.inspect=c,c.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]},c.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=g,t.isString=d,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=b,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=[S(e.getHours()),S(e.getMinutes()),S(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,u.EventEmitter=u,u.prototype._events=void 0,u.prototype._eventsCount=0,u.prototype._maxListeners=void 0;var s=10;function c(e){return void 0===e._maxListeners?u.defaultMaxListeners:e._maxListeners}function a(e,n,r,o){var i,u,s,a;if("function"!=typeof r)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r);if(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),s=u[n]),void 0===s)s=u[n]=r,++e._eventsCount;else if("function"==typeof s?s=u[n]=o?[r,s]:[s,r]:o?s.unshift(r):s.push(r),(i=c(e))>0&&s.length>i&&!s.warned){s.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(n)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=e,f.type=n,f.count=s.length,a=f,t&&t.warn&&t.warn(a)}return e}function f(){for(var e=[],t=0;t<arguments.length;t++)e.push(arguments[t]);this.fired||(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,o(this.listener,this.target,e))}function l(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},o=f.bind(r);return o.listener=n,r.wrapFn=o,o}function p(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):y(o,o.length)}function h(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 y(e,t){for(var n=new Array(t),r=0;r<t;++r)n[r]=e[r];return n}Object.defineProperty(u,"defaultMaxListeners",{enumerable:!0,get:function(){return s},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+".");s=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 c(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 s=new Error("Unhandled error."+(u?" ("+u.message+")":""));throw s.context=u,s}var c=i[e];if(void 0===c)return!1;if("function"==typeof c)o(c,this,t);else{var a=c.length,f=y(c,a);for(n=0;n<a;++n)o(f[n],this,t)}return!0},u.prototype.addListener=function(e,t){return a(this,e,t,!1)},u.prototype.on=u.prototype.addListener,u.prototype.prependListener=function(e,t){return a(this,e,t,!0)},u.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.on(e,l(this,e,t)),this},u.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);return this.prependListener(e,l(this,e,t)),this},u.prototype.removeListener=function(e,t){var n,r,o,i,u;if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t);if(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 p(this,e,!0)},u.prototype.rawListeners=function(e){return p(this,e,!1)},u.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):h.call(e,t)},u.prototype.listenerCount=h,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 function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function o(e){return(o="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 i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function u(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function s(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 c(e,t,n){return t&&s(e.prototype,t),n&&s(e,n),e}function a(e,t){return(a=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var f=n(3),l=n(12),p=n(13),h=Symbol("state"),y=Symbol("open"),m=Symbol("closed"),v=Symbol("half-open"),g=Symbol("pending-close"),d=Symbol("shutdown"),b=Symbol("fallback"),w=Symbol("status"),O=Symbol("name"),E=Symbol("group"),j=new WeakMap,x=Symbol("Enabled"),T=Symbol("warming-up"),S=Symbol("volume-threshold"),k=Symbol("our-error"),P=Symbol("reset-timeout"),_=Symbol("warmup-timeout"),L="options.maxFailures is deprecated. Please use options.errorThresholdPercentage",A=function(e){function n(e){var r,s,c,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),s=this,c=i(n).call(this),(r=!c||"object"!==o(c)&&"function"!=typeof c?u(s):c).options=a,r.options.timeout=a.timeout||1e4,r.options.resetTimeout=a.resetTimeout||3e4,r.options.errorThresholdPercentage=a.errorThresholdPercentage||50,r.options.rollingCountTimeout=a.rollingCountTimeout||1e4,r.options.rollingCountBuckets=a.rollingCountBuckets||10,r.options.rollingPercentilesEnabled=!1!==a.rollingPercentilesEnabled,r.options.capacity=Number.isInteger(a.capacity)?a.capacity:Number.MAX_SAFE_INTEGER,r.options.errorFilter=a.errorFilter||function(e){return!1},r.semaphore=new p(r.options.capacity),r[S]=Number.isInteger(a.volumeThreshold)?a.volumeThreshold:0,r[T]=!0===a.allowWarmUp,r[w]=new l(r.options),r[h]=m,r[b]=null,r[g]=!1,r[O]=a.name||e.name||F(),r[E]=a.group||r[O],r[x]=!1!==a.enabled,r[T]){var f=r[_]=setTimeout((function(e){return r[T]=!1}),r.options.rollingCountTimeout);"function"==typeof f.unref&&f.unref()}r.action="function"!=typeof e?function(t){return Promise.resolve(e)}:e,a.maxFailures&&t.error(L);var y,d=function(e){return function(t,n){return r[w].increment(e,n)}};return r.on("success",d("successes")),r.on("failure",d("failures")),r.on("fallback",d("fallbacks")),r.on("timeout",d("timeouts")),r.on("fire",d("fires")),r.on("reject",d("rejects")),r.on("cacheHit",d("cacheHits")),r.on("cacheMiss",d("cacheMisses")),r.on("open",(function(e){return r[w].open()})),r.on("close",(function(e){return r[w].close()})),r.on("semaphoreLocked",d("semaphoreRejections")),r.on("open",(y=u(r),function(e){var t=y[P]=setTimeout((function(){y[h]=v,y[g]=!0,y.emit("halfOpen",y.options.resetTimeout)}),y.options.resetTimeout);"function"==typeof t.unref&&t.unref()})),r.on("success",(function(e){r.halfOpen&&r.close()})),r.options.cache&&j.set(u(r),void 0),r}return 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&&a(e,t)}(n,e),c(n,null,[{key:"isOurError",value:function(e){return!!e[k]}}]),c(n,[{key:"close",value:function(){this[h]!==m&&(this[P]&&clearTimeout(this[P]),this[h]=m,this[g]=!1,this.emit("close"))}},{key:"open",value:function(){this[h]!==y&&(this[h]=y,this[g]=!1,this.emit("open"))}},{key:"shutdown",value:function(){this.disable(),this.removeAllListeners(),this[P]&&clearTimeout(this[P]),this[_]&&clearTimeout(this[_]),this.status.shutdown(),this[h]=d,this.emit("shutdown")}},{key:"fallback",value:function(e){var t=e;return e instanceof n&&(t=function(){return e.fire.apply(e,arguments)}),this[b]=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=M("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,s=Array.prototype.slice.call(o);if(this.emit("fire",s),void 0!==j.get(this))return this.emit("cacheHit"),j.get(this);if(this.options.cache&&this.emit("cacheMiss"),!this[x]){var c=this.action.apply(e,s);return"function"==typeof c.then?c:Promise.resolve(c)}if(!this.closed&&!this.pendingClose){var a=M("Breaker is open","EOPENBREAKER");return this.emit("reject",a),D(this,a,s)||Promise.reject(a)}this[g]=!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=M("Timed out after ".concat(t.options.timeout,"ms"),"ETIMEDOUT"),i=Date.now()-o;t.semaphore.release(),t.emit("timeout",e,i,s),C(e,t,u,s,i,n,r)}),t.options.timeout));try{var i=t.action.apply(e,s),c="function"==typeof i.then?i:Promise.resolve(i);c.then((function(e){f||(clearTimeout(u),t.emit("success",e,Date.now()-o),t.semaphore.release(),n(e),t.options.cache&&j.set(t,c))})).catch((function(e){if(!f){t.semaphore.release();var i=Date.now()-o;C(e,t,u,s,i,n,r)}}))}catch(e){t.semaphore.release();var a=Date.now()-o;C(e,t,u,s,a,n,r)}}else{var l=Date.now()-o,p=M("Semaphore locked","ESEMLOCKED");t.emit("semaphoreLocked",p,l),C(p,t,u,s,l,n,r)}}))}},{key:"clearCache",value:function(){j.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[x]=!0}},{key:"disable",value:function(){this[x]=!1}},{key:"isShutdown",get:function(){return this[h]===d}},{key:"name",get:function(){return this[O]}},{key:"group",get:function(){return this[E]}},{key:"pendingClose",get:function(){return this[g]}},{key:"closed",get:function(){return this[h]===m}},{key:"opened",get:function(){return this[h]===y}},{key:"halfOpen",get:function(){return this[h]===v}},{key:"status",get:function(){return this[w]}},{key:"stats",get:function(){return this[w].stats}},{key:"enabled",get:function(){return this[x]}},{key:"warmUp",get:function(){return this[T]}},{key:"volumeThreshold",get:function(){return this[S]}}]),n}(f);function C(e,t,n,r,o,i,u){clearTimeout(n),t.options.errorFilter(e)?t.emit("success",e,o):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,o);var s=D(t,e,r);s?i(s):u(e)}function D(e,t,n){if(e[b]){var o=e[b].apply(e[b],[].concat(r(n),[t]));return e.emit("fallback",o,t),o instanceof Promise?o:Promise.resolve(o)}}function M(e,t){var n=new Error(e);return n.code=t,n[k]=!0,n}var F=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=A}).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 s(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 c,a=[],f=!1,l=-1;function p(){f&&c&&(f=!1,c.length?a=c.concat(a):l=-1,a.length&&h())}function h(){if(!f){var e=s(p);f=!0;for(var t=a.length;t;){for(c=a,a=[];++l<t;)c&&c[l].run();l=-1,t=a.length}c=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||s(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. |
{ | ||
"name": "opossum", | ||
"version": "4.2.2", | ||
"version": "4.2.3-0", | ||
"author": "Red Hat, Inc.", | ||
@@ -11,3 +11,2 @@ "license": "Apache-2.0", | ||
}, | ||
"main": "dist/opossum.js", | ||
"scripts": { | ||
@@ -18,4 +17,4 @@ "prebuild": "npm run lint", | ||
"build:docs": "npm run build:docs:html && npm run build:docs:markdown", | ||
"build:docs:html": "documentation build lib -f html -o docs --config documentation.yml", | ||
"build:docs:markdown": "documentation build lib -f md -o docs/opossum.md", | ||
"build:docs:html": "documentation build index.js -f html -o docs --config documentation.yml", | ||
"build:docs:markdown": "documentation build index.js -f md -o docs/opossum.md", | ||
"pretest": "npm run lint", | ||
@@ -29,3 +28,3 @@ "test": "nyc tape test/*.js | tap-spec", | ||
"release": "standard-version -s -a", | ||
"lint": "standardx test/*.js lib/*.js test/*/*.js", | ||
"lint": "standardx test/*.js index.js lib/*.js test/*/*.js", | ||
"clean": "rm -rf node_modules dist/*.js test/browser/webpack-test.js" | ||
@@ -47,4 +46,6 @@ }, | ||
"LICENSE", | ||
"index.js", | ||
"lib", | ||
"dist", | ||
"docs/opossum.md" | ||
"doc/opossum.md" | ||
], | ||
@@ -51,0 +52,0 @@ "bugs": { |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
777898
14
3963
1