-
Notifications
You must be signed in to change notification settings - Fork 12
/
ng-di.min.js
13 lines (12 loc) · 6.46 KB
/
ng-di.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
/*!
* ng-di - v0.2.1 - 2015-11-15
* Dependency Injection for Javascript. Both for Browser and Node
* https://github.com/jmendiara/ng-di
* Adaptation done 2015 Javier Mendiara Cañardo
* Licensed MIT
* https://github.com/jmendiara/ng-di/blob/master/LICENSE-MIT
*
* All credits must go to the AngularJS team.
* AngularJS Licensed under MIT License.
*/
(function(t,n){function e(t){var n,r=t.lastIndexOf("/");if(-1===r)throw Error('Module "'+t+'" not found');return n=t.substr(r+1),e.modules[n]||(e.modules[n]={})}e.modules={},t.di=e("./ng-di"),function(t){"use strict";function n(t){return t&&"number"==typeof t.length?"function"!=typeof t.hasOwnProperty&&"function"!=typeof t.constructor?!0:"[object Object]"!==Object.prototype.toString.call(t)||"function"==typeof t.callee:!1}function e(t,r,o){var i;if(t)if(a(t))for(i in t)"prototype"!=i&&"length"!=i&&"name"!=i&&t.hasOwnProperty(i)&&r.call(o,t[i],i);else if(t.forEach&&t.forEach!==e)t.forEach(r,o);else if(n(t))for(i=0;t.length>i;i++)r.call(o,t[i],i);else for(i in t)t.hasOwnProperty(i)&&r.call(o,t[i],i);return t}function r(t){return e(arguments,function(n){n!==t&&e(n,function(n,e){t[e]=n})}),t}function o(t){return function(n,e){t(e,n)}}function i(){for(var t,n=l.length;n;){if(n--,t=l[n].charCodeAt(0),57==t)return l[n]="A",l.join("");if(90!=t)return l[n]=String.fromCharCode(t+1),l.join("");l[n]="0"}return l.unshift("0"),l.join("")}function u(t){return function(){return t}}function c(t){return null!=t&&"object"==typeof t}function s(t){return"string"==typeof t}function f(t){return"[object Array]"==Object.prototype.toString.apply(t)}function a(t){return"function"==typeof t}function p(t,n,e){if(!t)throw Error("Argument '"+(n||"?")+"' is "+(e||"required"));return t}function h(t,n,e){return e&&f(t)&&(t=t[t.length-1]),p(a(t),n,"not a function, got "+(t&&"object"==typeof t?t.constructor.name||"Object":typeof t)),t}var l=["0","0","0"];t.forEach=e,t.reverseParams=o,t.extend=r,t.nextUid=i,t.assertArgFn=h,t.valueFn=u,t.isString=s,t.isArray=f,t.isFunction=a,t.isObject=c}("undefined"==typeof exports?e("./utils"):exports),function(t){"use strict";t.setupModuleLoader=function(t){function n(t,n,e){return t[n]||(t[n]=e())}return n(t,"module",function(){var t={};return function(e,r,o){return r&&t.hasOwnProperty(e)&&(t[e]=null),n(t,e,function(){function t(t,e,r){return function(){return n[r||"push"]([t,e,arguments]),c}}if(!r)throw Error("No module: "+e);var n=[],i=[],u=t("$injector","invoke"),c={_invokeQueue:n,_runBlocks:i,requires:r,name:e,provider:t("$provide","provider"),factory:t("$provide","factory"),service:t("$provide","service"),value:t("$provide","value"),constant:t("$provide","constant","unshift"),config:u,run:function(t){return i.push(t),this}};return o&&u(o),c})}})}}("undefined"==typeof exports?e("./module"):exports),function(t){"use strict";var r=e("./utils"),o=function o(t){var e,o=typeof t;return"object"===o&&null!==t?"function"==typeof(e=t.$$hashKey)?e=t.$$hashKey():e===n&&(e=t.$$hashKey=r.nextUid()):e=t,o+":"+e};t.HashMap=function(t){r.forEach(t,this.put,this)},t.HashMap.prototype={put:function(t,n){this[o(t)]=n},get:function(t){return this[o(t)]},remove:function(t){var n=this[t=o(t)];return delete this[t],n}}}("undefined"==typeof exports?e("./hashmap"):exports),function(t){"use strict";var r=e("./hashmap"),o=e("./utils"),i=e("./ng-di"),u=/^function\s*[^\(]*\(\s*([^\)]*)\)/m,c=/,/,s=/^\s*(_?)(\S+?)\1\s*$/,f=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,a=t.annotate=function a(t){var n,e,r,i;return"function"==typeof t?(n=t.$inject)||(n=[],e=(""+t).replace(f,""),r=e.match(u),o.forEach(r[1].split(c),function(t){t.replace(s,function(t,e,r){n.push(r)})}),t.$inject=n):o.isArray(t)?(i=t.length-1,o.assertArgFn(t[i],"fn"),n=t.slice(0,i)):o.assertArgFn(t,"fn",!0),n};t.createInjector=function(t){function e(t){return function(e,r){return o.isObject(e)?(o.forEach(e,o.reverseParams(t)),n):t(e,r)}}function u(t,n){if((o.isFunction(n)||o.isArray(n))&&(n=$.instantiate(n)),!n.$get)throw Error("Provider "+t+" must define $get factory method.");return j[t+y]=n}function c(t,n){return u(t,{$get:n})}function s(t,n){return c(t,["$injector",function(t){return t.instantiate(n)}])}function f(t,n){return c(t,o.valueFn(n))}function p(t,n){j[t]=n,w[t]=n}function h(t,n){var e=$.get(t+y),r=e.$get;e.$get=function(){var t=E.invoke(r,e);return E.invoke(n,null,{$delegate:t})}}function l(t){var n=[];return o.forEach(t,function(t){if(!m.get(t))if(m.put(t,!0),o.isString(t)){var e=i.module(t);n=n.concat(l(e.requires)).concat(e._runBlocks);try{for(var r=e._invokeQueue,u=0,c=r.length;c>u;u++){var s=r[u],f=$.get(s[0]);f[s[1]].apply(f,s[2])}}catch(a){throw a.message&&(a.message+=" from "+t),a}}else if(o.isFunction(t))try{n.push($.invoke(t))}catch(a){throw a.message&&(a.message+=" from "+t),a}else if(o.isArray(t))try{n.push($.invoke(t))}catch(a){throw a.message&&(a.message+=" from "+(t[t.length-1]+"")),a}else o.assertArgFn(t,"module")}),n}function d(t,n){function e(e){if("string"!=typeof e)throw Error("Service name expected");if(t.hasOwnProperty(e)){if(t[e]===v)throw Error("Circular dependency: "+g.join(" <- "));return t[e]}try{return g.unshift(e),t[e]=v,t[e]=n(e)}finally{g.shift()}}function r(t,n,r){var o,i,u,c=[],s=a(t);for(i=0,o=s.length;o>i;i++)u=s[i],c.push(r&&r.hasOwnProperty(u)?r[u]:e(u));switch(t.$inject||(t=t[o]),n?-1:c.length){case 0:return t();case 1:return t(c[0]);case 2:return t(c[0],c[1]);case 3:return t(c[0],c[1],c[2]);case 4:return t(c[0],c[1],c[2],c[3]);case 5:return t(c[0],c[1],c[2],c[3],c[4]);case 6:return t(c[0],c[1],c[2],c[3],c[4],c[5]);case 7:return t(c[0],c[1],c[2],c[3],c[4],c[5],c[6]);case 8:return t(c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7]);case 9:return t(c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7],c[8]);case 10:return t(c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7],c[8],c[9]);default:return t.apply(n,c)}}function i(t,n){var e,i,u=function(){};return u.prototype=(o.isArray(t)?t[t.length-1]:t).prototype,e=new u,i=r(t,e,n),o.isObject(i)?i:e}return{invoke:r,instantiate:i,get:e,annotate:a}}var v={},y="Provider",g=[],m=new r.HashMap,j={$provide:{provider:e(u),factory:e(c),service:e(s),value:e(f),constant:e(p),decorator:h}},$=j.$injector=d(j,function(){throw Error("Unknown provider: "+g.join(" <- "))}),w={},E=w.$injector=d(w,function(t){var n=$.get(t+y);return E.invoke(n.$get,n)});return o.forEach(l(t),function(t){E.invoke(t||function(){})}),E}}("undefined"==typeof exports?e("./injector"):exports),function(t){"use strict";t.module=e("./module").setupModuleLoader(t);var n=e("./injector");t.injector=n.createInjector,t.annotate=n.annotate}("undefined"==typeof exports?e("./ng-di"):exports)})(this);