express-locator
Version:
a service locator
1 lines • 6.81 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.reduxMethods=e():t.reduxMethods=e()}(window,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function i(t){var e="function"==typeof Map?new Map:void 0;return(i=function(t){if(null===t)return null;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return c(t,arguments,f(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),u(r,t)})(t)}function c(t,e,r){return(c=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}()?Reflect.construct:function(t,e,r){var n=[null];n.push.apply(n,e);var o=new(Function.bind.apply(t,n));return r&&u(o,r.prototype),o}).apply(null,arguments)}function u(t,e){return(u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function f(t){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}r.r(e);var a=function(t){function e(){var t,r;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);for(var i=arguments.length,c=new Array(i),u=0;u<i;u++)c[u]=arguments[u];return r=function(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?o(t):e}(this,(t=f(e)).call.apply(t,[this].concat(c))),Error.captureStackTrace&&Error.captureStackTrace(o(o(r)),e),r.isControlled=!0,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&u(t,e)}(e,i(Error)),e}();function s(t){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var l=function t(e,r){var n=this;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),"object"!==s(e)||Array.isArray(e))throw new Error("Locator must be provided to class in an object key-value pair");Object.keys(e).forEach(function(t){n[t]=e[t]}),Array.isArray(r)&&r.forEach(function(t){n[t]=n.locator.get(t)})};function y(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=[],n=!0,o=!1,i=void 0;try{for(var c,u=t[Symbol.iterator]();!(n=(c=u.next()).done)&&(r.push(c.value),!e||r.length!==e);n=!0);}catch(t){o=!0,i=t}finally{try{n||null==u.return||u.return()}finally{if(o)throw i}}return r}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function p(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}var h=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.registry={Error:{},Instance:{}},this.cache={Error:a,Instance:l}}return function(t,e,r){e&&p(t.prototype,e),r&&p(t,r)}(t,[{key:"config",value:function(t){this.configs=t;for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];this.register.apply(this,r)}},{key:"register",value:function(){for(var t=this,e=[],r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];n.forEach(function r(n){if(Array.isArray(n))n.forEach(r);else if("string"==typeof n)t.registry[n]={construct:n};else{var o=n.name,i=n.dependencies,c=n.config,u=n.construct,f=n.invoke,a=function(t,e){if(null==t)return{};var r,n,o={},i=Object.keys(t);for(n=0;n<i.length;n++)r=i[n],e.indexOf(r)>=0||(o[r]=t[r]);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(t);for(n=0;n<c.length;n++)r=c[n],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}(n,["name","dependencies","config","construct","invoke"]);if(o)t.registry[o]={config:c,construct:u,dependencies:i},f&&e.push(o);else{if(o||1!==Object.keys(a).length)throw new Error("No dependency name has been provided");var s=y(Object.keys(a),1)[0],l=a[s];t.registry[s]={config:c,construct:l,dependencies:i},f&&e.push(s)}}}),e.forEach(function(e){return t.get(e)})}},{key:"get",value:function(t){if(void 0===this.registry[t])throw new Error("".concat(t,": Attempting to retrieve unknown dependency"));if(void 0===this.cache[t]){var e=this.registry[t],n=e.construct,o=e.dependencies,i=void 0===o?[]:o,c=e.config;if(n)if("string"==typeof n){var u=n;this.cache[t]=r(1)(u)}else{var f={config:this.configs&&(c?this.configs:this.configs[t]),locator:this};if(n.prototype instanceof l){var a=n;this.cache[t]=new a(f,i)}else"function"==typeof n&&(this.cache[t]=n(f,i))}}if(!this.cache[t])throw new Error("".concat(t,": Dependency construction object is invalid"));return this.cache[t]}},{key:"clear",value:function(){this.registry={Error:{},Instance:{}},this.cache={Error:a,Instance:l}}}]),t}(),d=new h;r.d(e,"Locator",function(){return h}),d.Locator=h;e.default=d},function(t,e){function r(t){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}r.keys=function(){return[]},r.resolve=r,t.exports=r,r.id=1}])});