Comparing version 0.0.18 to 0.0.19
/** | ||
* jeefo : v0.0.17 | ||
* jeefo : v0.0.19 | ||
* Author : je3f0o, <je3f0o@gmail.com> | ||
@@ -421,3 +421,3 @@ * Homepage : https://github.com/je3f0o/jeefo | ||
* Created at : 2016-09-01 | ||
* Updated at : 2017-05-10 | ||
* Updated at : 2017-06-30 | ||
* Author : jeefo | ||
@@ -448,3 +448,3 @@ * Purpose : | ||
if (has(name)) { | ||
min_error("Duplicated provider '" + name + "' detected in module '" + module.name + "'."); | ||
min_error("Duplicated provider '" + name + "' detected in module '" + module_name + "'."); | ||
} | ||
@@ -458,5 +458,3 @@ injector.register(name, definition); | ||
function resolve (name) { | ||
if (name === "$injector") { | ||
return $q.when(self); | ||
} else if (local_values.hasOwnProperty(name)) { | ||
if (local_values.hasOwnProperty(name)) { | ||
return $q.when(local_values[name]); | ||
@@ -471,5 +469,3 @@ } else if (definitions.hasOwnProperty(name)) { | ||
function resolve_sync (name) { | ||
if (name === "$injector") { | ||
return self; | ||
} else if (local_values.hasOwnProperty(name)) { | ||
if (local_values.hasOwnProperty(name)) { | ||
return local_values[name]; | ||
@@ -572,2 +568,6 @@ } else if (definitions.hasOwnProperty(name)) { | ||
} | ||
injector.definitions.$injector = { | ||
fn : return_public_injector, | ||
dependencies : empty_array, | ||
}; | ||
@@ -591,2 +591,4 @@ container[module_name] = { | ||
function return_public_injector () { return public_injector; } | ||
// Do not use $injector.register inside extend function. | ||
@@ -593,0 +595,0 @@ // Which can be called each inherited modules. |
/** | ||
* jeefo : v0.0.17 | ||
* jeefo : v0.0.19 | ||
* Author : je3f0o, <je3f0o@gmail.com> | ||
@@ -8,2 +8,2 @@ * Homepage : https://github.com/je3f0o/jeefo | ||
**/ | ||
!function(){"use strict";var e=function(){var e=Array,n=e.isArray,r=Object.keys,t=function(e){for(var n,t,i,o=1;o<arguments.length;++o)if(n=arguments[o])for(t=r(n),i=t.length-1;i>=0;e[t[i]]=n[t[i]],--i);return e},i=function(e){throw new Error(e)},o=function(n,r){var t=[],o={};return function s(u,c){for(var d=c.length-1,a=new e(d+1),f=r(u);d>=0;a[d]=c[d],--d);for(a.push(u),o[u]=!0,d=0;d<f.length;++d)a.indexOf(f[d])>=0&&i("Circular dependency '"+f[d]+" is required by '"+n+"' : "+a.join(" -> ")),o.hasOwnProperty(f[d])||s(f[d],a);-1===t.indexOf(u)&&t.push(u)}(n,[]),t},s=function(e){function n(){return 0===i}function r(e,n){return new s(function(r,s){switch(i){case 1:return r(e(t));case 2:return s(n(t));default:o[c]=e,o[c+1]=n,o[c+2]=r,o[c+3]=s,c+=4}})}var t,i=0,o=[],u=this,c=0;return u.then=r,u.state="pending...",u.is_pending=n,e(function(e){if(0===i){i=1,u.state="resolved",u.value=t=e;for(var n=0;n<c;n+=4)e=o[n](t),e&&"JEEFO_PROMISE"===e.type?e.then(o[n+2],o[n+3]):o[n+2](e);o=null,c=0}},function(e){if(0===i){i=2,u.state="rejected",u.reason=t=e;for(var n=1;n<c;n+=4)e=o[n](t),e&&"JEEFO_PROMISE"===e.type?e.then(o[n+1],o[n+2]):o[n+2](e);o=null,c=0}}),u};s.prototype.type="JEEFO_PROMISE";var u={defer:function(){var e={};return e.promise=new s(function(n,r){e.resolve=n,e.reject=r}),e},when:function(e){return e&&"JEEFO_PROMISE"===e.type?e:new s(function(n){n(e)})},for_each_async:function(e,n){function r(){++t<e.length?n.call(e,e[t],t,r,e):i.resolve()}var t=-1,i=this.defer();return r(),i.promise},all:function(e){for(var n,r=0,t=this.defer(),i=0;r<e.length;++r)(n=e[r])&&"JEEFO_PROMISE"===n.type&&(i+=1,n.then(function(n){return function(r){e[n]=r,0===--i&&t.resolve(e)}}(r)));return 0===i&&t.resolve(e),t.promise}},c=function(e){this.values=t({},e),this.definitions={}},d=[];c.prototype={register:function(n,r){if(r.dependencies){for(var t=new e(r.dependencies.length),o=t.length-1;o>=0;t[o]=r.dependencies[o],--o);(this.values.hasOwnProperty(n)||this.definitions.hasOwnProperty(n))&&i("Duplicated provider "+n+" detected."),this.definitions[n]={fn:r.fn,dependencies:t,is_constructor:!!r.is_constructor}}else this.definitions[n]={fn:r.fn,dependencies:d,is_constructor:!!r.is_constructor};return this},resolve:function(n,r){var t,s=this.values,c=this.definitions,d=r&&r.values||{},a=r&&r.definitions;return d.hasOwnProperty(n)?d[n]&&"JEEFO_PROMISE"===d[n].type?d[n]:u.when(d[n]):s.hasOwnProperty(n)?s[n]&&"JEEFO_PROMISE"===s[n].type?s[n]:u.when(s[n]):(t=o(n,function(e){return a&&a.hasOwnProperty(e)?a[e].dependencies:c.hasOwnProperty(e)?c[e].dependencies:void i("Injector '"+e+"' definition is not found.")}),u.for_each_async(t,function(n,r,t){var o,u;if(d.hasOwnProperty(n)||s.hasOwnProperty(n))return t();a&&a.hasOwnProperty(n)?(o=d,u=a[n]):(o=s,u=c[n]);for(var f=u.dependencies.length-1,p=new e(f+1);f>=0;--f)d.hasOwnProperty(u.dependencies[f])?p[f]=d[u.dependencies[f]]:s.hasOwnProperty(u.dependencies[f])?p[f]=s[u.dependencies[f]]:i("OMG");var h=u.fn.apply(null,p);u.is_constructor&&(h=new h),h&&"JEEFO_PROMISE"===h.type?h.then(function(e){o[n]=e,t()}):(o[n]=h,t())}).then(function(){return d.hasOwnProperty(n)?d[n]:s[n]}))},resolve_sync:function(n,r){var t,s=this,u=s.values,c=r&&r.values||{},d=s.definitions,a=r&&r.definitions;if(c.hasOwnProperty(n))return c[n];if(u.hasOwnProperty(n))return u[n];a&&a.hasOwnProperty(n)?t=c:d.hasOwnProperty(n)&&(t=u);for(var f=o(n,function(e){return a&&a.hasOwnProperty(e)?a[e].dependencies:d.hasOwnProperty(e)?d[e].dependencies:void i("Injector '"+e+"' definition is not found.")}),p=d[f.pop()],h=new e(p.dependencies.length),l=0;l<f.length;++l)c.hasOwnProperty(f[l])||u.hasOwnProperty(f[l])||s.resolve_sync(f[l],r);for(l=h.length-1;l>=0;--l)h[l]=c.hasOwnProperty(p.dependencies[l])?c[p.dependencies[l]]:u[p.dependencies[l]];return t[n]=p.fn.apply(null,h)}};var a=function(e,n,r,t){function o(e){return"$injector"===e||p.hasOwnProperty(e)||f.hasOwnProperty(e)}function s(e,r){return o(e)&&i("Duplicated provider '"+e+"' detected in module '"+module.name+"'."),n.register(e,r),t[e]=n.definitions[e],a}function c(t){return"$injector"===t?u.when(a):p.hasOwnProperty(t)?u.when(p[t]):f.hasOwnProperty(t)?n.resolve(t,r):void i("Module provider '"+t+"' definition is not found in '"+e+"' module.")}function d(t){return"$injector"===t?a:p.hasOwnProperty(t)?p[t]:f.hasOwnProperty(t)?n.resolve_sync(t,r):void i("Module provider '"+t+"' definition is not found in '"+e+"' module.")}var a=this,f=n.definitions,p=r.values;return a.has=o,a.resolve=c,a.register=s,a.resolve_sync=d,a},f={dependencies:d},p=function(n,r,t){if("function"===typeof r)return{fn:r,name:n,dependencies:d};if("string"===typeof r)return{fn:t,name:n,dependencies:[r]};for(var i=r.length-1,o=new e(i+1);i>=0;o[i]=r[i],--i);return{fn:t,name:n,dependencies:o}},h={values:{$q:u,Array:e,is_array:n,Injector:c,"object.keys":r,"object.assign":t,make_injectable:p,"sorts.topological":o},definitions:{$q:f,Array:f,is_array:f,Injector:f,"object.keys":f,"object.assign":f,make_injectable:f,"sorts.topological":f}},l=function(n,r,s){function d(){var e=arguments[0],r=p.apply(null,arguments);return w.hasOwnProperty(e)&&i("'"+e+"' extends already registered in '"+n+"' module."),P[_++]=r,f(w,r),w}function f(n,r){var t=new e(r.dependencies.length);u.for_each_async(r.dependencies,function(e,n,r){E.resolve(e).then(function(e){t[n]=e,r()})}).then(function(){n[r.name]=r.fn.apply(n,t)})}var l,y,v,w={name:n,extend:d},O=new c,P=[],_=0,g={},E=new a(n,O,h,g),m=[];for(y=o(n,function(e){return s[e]?s[e].requires:n===e?r:void i("'"+e+"' module is not found.")}),v=y.length>1?new e(y.length-1):[],l=0;l<v.length;++l)m=m.concat(s[y[l]].extenders),t(O.definitions,s[y[l]].new_definitions);for(s[n]={name:n,requires:r,instance:w,injector:O,extenders:P,public_injector:E,new_definitions:g},l=0;l<m.length;++l)f(w,m[l]);return w},y=function(){};return y.prototype={use:function(e){return e(this),this}},{create:function(){function e(e,t){return n(t)?(r.hasOwnProperty(e)&&i("Duplicated module '"+e+"' is detected."),l(e,t,r)):(r.hasOwnProperty(e)||i("'"+e+"' module is not found."),r[e].instance)}var r={},t=new y;return t.module=e,t}}}();window.jeefo=e.create()}(); | ||
!function(){"use strict";var e=function(){var e=Array,n=e.isArray,r=Object.keys,t=function(e){for(var n,t,i,o=1;o<arguments.length;++o)if(n=arguments[o])for(t=r(n),i=t.length-1;i>=0;e[t[i]]=n[t[i]],--i);return e},i=function(e){throw new Error(e)},o=function(n,r){var t=[],o={};return function s(u,c){for(var d=c.length-1,f=new e(d+1),a=r(u);d>=0;f[d]=c[d],--d);for(f.push(u),o[u]=!0,d=0;d<a.length;++d)f.indexOf(a[d])>=0&&i("Circular dependency '"+a[d]+" is required by '"+n+"' : "+f.join(" -> ")),o.hasOwnProperty(a[d])||s(a[d],f);-1===t.indexOf(u)&&t.push(u)}(n,[]),t},s=function(e){function n(){return 0===i}function r(e,n){return new s(function(r,s){switch(i){case 1:return r(e(t));case 2:return s(n(t));default:o[c]=e,o[c+1]=n,o[c+2]=r,o[c+3]=s,c+=4}})}var t,i=0,o=[],u=this,c=0;return u.then=r,u.state="pending...",u.is_pending=n,e(function(e){if(0===i){i=1,u.state="resolved",u.value=t=e;for(var n=0;n<c;n+=4)e=o[n](t),e&&"JEEFO_PROMISE"===e.type?e.then(o[n+2],o[n+3]):o[n+2](e);o=null,c=0}},function(e){if(0===i){i=2,u.state="rejected",u.reason=t=e;for(var n=1;n<c;n+=4)e=o[n](t),e&&"JEEFO_PROMISE"===e.type?e.then(o[n+1],o[n+2]):o[n+2](e);o=null,c=0}}),u};s.prototype.type="JEEFO_PROMISE";var u={defer:function(){var e={};return e.promise=new s(function(n,r){e.resolve=n,e.reject=r}),e},when:function(e){return e&&"JEEFO_PROMISE"===e.type?e:new s(function(n){n(e)})},for_each_async:function(e,n){function r(){++t<e.length?n.call(e,e[t],t,r,e):i.resolve()}var t=-1,i=this.defer();return r(),i.promise},all:function(e){for(var n,r=0,t=this.defer(),i=0;r<e.length;++r)(n=e[r])&&"JEEFO_PROMISE"===n.type&&(i+=1,n.then(function(n){return function(r){e[n]=r,0===--i&&t.resolve(e)}}(r)));return 0===i&&t.resolve(e),t.promise}},c=function(e){this.values=t({},e),this.definitions={}},d=[];c.prototype={register:function(n,r){if(r.dependencies){for(var t=new e(r.dependencies.length),o=t.length-1;o>=0;t[o]=r.dependencies[o],--o);(this.values.hasOwnProperty(n)||this.definitions.hasOwnProperty(n))&&i("Duplicated provider "+n+" detected."),this.definitions[n]={fn:r.fn,dependencies:t,is_constructor:!!r.is_constructor}}else this.definitions[n]={fn:r.fn,dependencies:d,is_constructor:!!r.is_constructor};return this},resolve:function(n,r){var t,s=this.values,c=this.definitions,d=r&&r.values||{},f=r&&r.definitions;return d.hasOwnProperty(n)?d[n]&&"JEEFO_PROMISE"===d[n].type?d[n]:u.when(d[n]):s.hasOwnProperty(n)?s[n]&&"JEEFO_PROMISE"===s[n].type?s[n]:u.when(s[n]):(t=o(n,function(e){return f&&f.hasOwnProperty(e)?f[e].dependencies:c.hasOwnProperty(e)?c[e].dependencies:void i("Injector '"+e+"' definition is not found.")}),u.for_each_async(t,function(n,r,t){var o,u;if(d.hasOwnProperty(n)||s.hasOwnProperty(n))return t();f&&f.hasOwnProperty(n)?(o=d,u=f[n]):(o=s,u=c[n]);for(var a=u.dependencies.length-1,p=new e(a+1);a>=0;--a)d.hasOwnProperty(u.dependencies[a])?p[a]=d[u.dependencies[a]]:s.hasOwnProperty(u.dependencies[a])?p[a]=s[u.dependencies[a]]:i("OMG");var h=u.fn.apply(null,p);u.is_constructor&&(h=new h),h&&"JEEFO_PROMISE"===h.type?h.then(function(e){o[n]=e,t()}):(o[n]=h,t())}).then(function(){return d.hasOwnProperty(n)?d[n]:s[n]}))},resolve_sync:function(n,r){var t,s=this,u=s.values,c=r&&r.values||{},d=s.definitions,f=r&&r.definitions;if(c.hasOwnProperty(n))return c[n];if(u.hasOwnProperty(n))return u[n];f&&f.hasOwnProperty(n)?t=c:d.hasOwnProperty(n)&&(t=u);for(var a=o(n,function(e){return f&&f.hasOwnProperty(e)?f[e].dependencies:d.hasOwnProperty(e)?d[e].dependencies:void i("Injector '"+e+"' definition is not found.")}),p=d[a.pop()],h=new e(p.dependencies.length),l=0;l<a.length;++l)c.hasOwnProperty(a[l])||u.hasOwnProperty(a[l])||s.resolve_sync(a[l],r);for(l=h.length-1;l>=0;--l)h[l]=c.hasOwnProperty(p.dependencies[l])?c[p.dependencies[l]]:u[p.dependencies[l]];return t[n]=p.fn.apply(null,h)}};var f=function(e,n,r,t){function o(e){return"$injector"===e||p.hasOwnProperty(e)||a.hasOwnProperty(e)}function s(r,s){return o(r)&&i("Duplicated provider '"+r+"' detected in module '"+e+"'."),n.register(r,s),t[r]=n.definitions[r],f}function c(t){return p.hasOwnProperty(t)?u.when(p[t]):a.hasOwnProperty(t)?n.resolve(t,r):void i("Module provider '"+t+"' definition is not found in '"+e+"' module.")}function d(t){return p.hasOwnProperty(t)?p[t]:a.hasOwnProperty(t)?n.resolve_sync(t,r):void i("Module provider '"+t+"' definition is not found in '"+e+"' module.")}var f=this,a=n.definitions,p=r.values;return f.has=o,f.resolve=c,f.register=s,f.resolve_sync=d,f},a={dependencies:d},p=function(n,r,t){if("function"===typeof r)return{fn:r,name:n,dependencies:d};if("string"===typeof r)return{fn:t,name:n,dependencies:[r]};for(var i=r.length-1,o=new e(i+1);i>=0;o[i]=r[i],--i);return{fn:t,name:n,dependencies:o}},h={values:{$q:u,Array:e,is_array:n,Injector:c,"object.keys":r,"object.assign":t,make_injectable:p,"sorts.topological":o},definitions:{$q:a,Array:a,is_array:a,Injector:a,"object.keys":a,"object.assign":a,make_injectable:a,"sorts.topological":a}},l=function(n,r,s){function a(){return m}function l(){var e=arguments[0],r=p.apply(null,arguments);return P.hasOwnProperty(e)&&i("'"+e+"' extends already registered in '"+n+"' module."),g[E++]=r,y(P,r),P}function y(n,r){var t=new e(r.dependencies.length);u.for_each_async(r.dependencies,function(e,n,r){m.resolve(e).then(function(e){t[n]=e,r()})}).then(function(){n[r.name]=r.fn.apply(n,t)})}var v,w,O,P={name:n,extend:l},_=new c,g=[],E=0,j={},m=new f(n,_,h,j),I=[];for(w=o(n,function(e){return s[e]?s[e].requires:n===e?r:void i("'"+e+"' module is not found.")}),O=w.length>1?new e(w.length-1):[],v=0;v<O.length;++v)I=I.concat(s[w[v]].extenders),t(_.definitions,s[w[v]].new_definitions);for(_.definitions.$injector={fn:a,dependencies:d},s[n]={name:n,requires:r,instance:P,injector:_,extenders:g,public_injector:m,new_definitions:j},v=0;v<I.length;++v)y(P,I[v]);return P},y=function(){};return y.prototype={use:function(e){return e(this),this}},{create:function(){function e(e,t){return n(t)?(r.hasOwnProperty(e)&&i("Duplicated module '"+e+"' is detected."),l(e,t,r)):(r.hasOwnProperty(e)||i("'"+e+"' module is not found."),r[e].instance)}var r={},t=new y;return t.module=e,t}}}();window.jeefo=e.create()}(); |
/** | ||
* jeefo : v0.0.17 | ||
* jeefo : v0.0.19 | ||
* Author : je3f0o, <je3f0o@gmail.com> | ||
@@ -424,3 +424,3 @@ * Homepage : https://github.com/je3f0o/jeefo | ||
* Created at : 2016-09-01 | ||
* Updated at : 2017-05-10 | ||
* Updated at : 2017-06-30 | ||
* Author : jeefo | ||
@@ -451,3 +451,3 @@ * Purpose : | ||
if (has(name)) { | ||
min_error("Duplicated provider '" + name + "' detected in module '" + module.name + "'."); | ||
min_error("Duplicated provider '" + name + "' detected in module '" + module_name + "'."); | ||
} | ||
@@ -461,5 +461,3 @@ injector.register(name, definition); | ||
function resolve (name) { | ||
if (name === "$injector") { | ||
return $q.when(self); | ||
} else if (local_values.hasOwnProperty(name)) { | ||
if (local_values.hasOwnProperty(name)) { | ||
return $q.when(local_values[name]); | ||
@@ -474,5 +472,3 @@ } else if (definitions.hasOwnProperty(name)) { | ||
function resolve_sync (name) { | ||
if (name === "$injector") { | ||
return self; | ||
} else if (local_values.hasOwnProperty(name)) { | ||
if (local_values.hasOwnProperty(name)) { | ||
return local_values[name]; | ||
@@ -575,2 +571,6 @@ } else if (definitions.hasOwnProperty(name)) { | ||
} | ||
injector.definitions.$injector = { | ||
fn : return_public_injector, | ||
dependencies : empty_array, | ||
}; | ||
@@ -594,2 +594,4 @@ container[module_name] = { | ||
function return_public_injector () { return public_injector; } | ||
// Do not use $injector.register inside extend function. | ||
@@ -596,0 +598,0 @@ // Which can be called each inherited modules. |
/** | ||
* jeefo : v0.0.17 | ||
* jeefo : v0.0.19 | ||
* Author : je3f0o, <je3f0o@gmail.com> | ||
@@ -8,2 +8,2 @@ * Homepage : https://github.com/je3f0o/jeefo | ||
**/ | ||
"use strict";module.exports=function(){var e=Array,n=e.isArray,r=Object.keys,t=function(e){for(var n,t,i,o=1;o<arguments.length;++o)if(n=arguments[o])for(t=r(n),i=t.length-1;i>=0;e[t[i]]=n[t[i]],--i);return e},i=function(e){throw new Error(e)},o=function(n,r){var t=[],o={};return function s(u,c){for(var d=c.length-1,a=new e(d+1),f=r(u);d>=0;a[d]=c[d],--d);for(a.push(u),o[u]=!0,d=0;d<f.length;++d)a.indexOf(f[d])>=0&&i("Circular dependency '"+f[d]+" is required by '"+n+"' : "+a.join(" -> ")),o.hasOwnProperty(f[d])||s(f[d],a);-1===t.indexOf(u)&&t.push(u)}(n,[]),t},s=function(e){function n(){return 0===i}function r(e,n){return new s(function(r,s){switch(i){case 1:return r(e(t));case 2:return s(n(t));default:o[c]=e,o[c+1]=n,o[c+2]=r,o[c+3]=s,c+=4}})}var t,i=0,o=[],u=this,c=0;return u.then=r,u.state="pending...",u.is_pending=n,e(function(e){if(0===i){i=1,u.state="resolved",u.value=t=e;for(var n=0;n<c;n+=4)e=o[n](t),e&&"JEEFO_PROMISE"===e.type?e.then(o[n+2],o[n+3]):o[n+2](e);o=null,c=0}},function(e){if(0===i){i=2,u.state="rejected",u.reason=t=e;for(var n=1;n<c;n+=4)e=o[n](t),e&&"JEEFO_PROMISE"===e.type?e.then(o[n+1],o[n+2]):o[n+2](e);o=null,c=0}}),u};s.prototype.type="JEEFO_PROMISE";var u={defer:function(){var e={};return e.promise=new s(function(n,r){e.resolve=n,e.reject=r}),e},when:function(e){return e&&"JEEFO_PROMISE"===e.type?e:new s(function(n){n(e)})},for_each_async:function(e,n){function r(){++t<e.length?n.call(e,e[t],t,r,e):i.resolve()}var t=-1,i=this.defer();return r(),i.promise},all:function(e){for(var n,r=0,t=this.defer(),i=0;r<e.length;++r)(n=e[r])&&"JEEFO_PROMISE"===n.type&&(i+=1,n.then(function(n){return function(r){e[n]=r,0===--i&&t.resolve(e)}}(r)));return 0===i&&t.resolve(e),t.promise}},c=function(e){this.values=t({},e),this.definitions={}},d=[];c.prototype={register:function(n,r){if(r.dependencies){for(var t=new e(r.dependencies.length),o=t.length-1;o>=0;t[o]=r.dependencies[o],--o);(this.values.hasOwnProperty(n)||this.definitions.hasOwnProperty(n))&&i("Duplicated provider "+n+" detected."),this.definitions[n]={fn:r.fn,dependencies:t,is_constructor:!!r.is_constructor}}else this.definitions[n]={fn:r.fn,dependencies:d,is_constructor:!!r.is_constructor};return this},resolve:function(n,r){var t,s=this.values,c=this.definitions,d=r&&r.values||{},a=r&&r.definitions;return d.hasOwnProperty(n)?d[n]&&"JEEFO_PROMISE"===d[n].type?d[n]:u.when(d[n]):s.hasOwnProperty(n)?s[n]&&"JEEFO_PROMISE"===s[n].type?s[n]:u.when(s[n]):(t=o(n,function(e){return a&&a.hasOwnProperty(e)?a[e].dependencies:c.hasOwnProperty(e)?c[e].dependencies:void i("Injector '"+e+"' definition is not found.")}),u.for_each_async(t,function(n,r,t){var o,u;if(d.hasOwnProperty(n)||s.hasOwnProperty(n))return t();a&&a.hasOwnProperty(n)?(o=d,u=a[n]):(o=s,u=c[n]);for(var f=u.dependencies.length-1,p=new e(f+1);f>=0;--f)d.hasOwnProperty(u.dependencies[f])?p[f]=d[u.dependencies[f]]:s.hasOwnProperty(u.dependencies[f])?p[f]=s[u.dependencies[f]]:i("OMG");var h=u.fn.apply(null,p);u.is_constructor&&(h=new h),h&&"JEEFO_PROMISE"===h.type?h.then(function(e){o[n]=e,t()}):(o[n]=h,t())}).then(function(){return d.hasOwnProperty(n)?d[n]:s[n]}))},resolve_sync:function(n,r){var t,s=this,u=s.values,c=r&&r.values||{},d=s.definitions,a=r&&r.definitions;if(c.hasOwnProperty(n))return c[n];if(u.hasOwnProperty(n))return u[n];a&&a.hasOwnProperty(n)?t=c:d.hasOwnProperty(n)&&(t=u);for(var f=o(n,function(e){return a&&a.hasOwnProperty(e)?a[e].dependencies:d.hasOwnProperty(e)?d[e].dependencies:void i("Injector '"+e+"' definition is not found.")}),p=d[f.pop()],h=new e(p.dependencies.length),l=0;l<f.length;++l)c.hasOwnProperty(f[l])||u.hasOwnProperty(f[l])||s.resolve_sync(f[l],r);for(l=h.length-1;l>=0;--l)h[l]=c.hasOwnProperty(p.dependencies[l])?c[p.dependencies[l]]:u[p.dependencies[l]];return t[n]=p.fn.apply(null,h)}};var a=function(e,n,r,t){function o(e){return"$injector"===e||p.hasOwnProperty(e)||f.hasOwnProperty(e)}function s(e,r){return o(e)&&i("Duplicated provider '"+e+"' detected in module '"+module.name+"'."),n.register(e,r),t[e]=n.definitions[e],a}function c(t){return"$injector"===t?u.when(a):p.hasOwnProperty(t)?u.when(p[t]):f.hasOwnProperty(t)?n.resolve(t,r):void i("Module provider '"+t+"' definition is not found in '"+e+"' module.")}function d(t){return"$injector"===t?a:p.hasOwnProperty(t)?p[t]:f.hasOwnProperty(t)?n.resolve_sync(t,r):void i("Module provider '"+t+"' definition is not found in '"+e+"' module.")}var a=this,f=n.definitions,p=r.values;return a.has=o,a.resolve=c,a.register=s,a.resolve_sync=d,a},f={dependencies:d},p=function(n,r,t){if("function"===typeof r)return{fn:r,name:n,dependencies:d};if("string"===typeof r)return{fn:t,name:n,dependencies:[r]};for(var i=r.length-1,o=new e(i+1);i>=0;o[i]=r[i],--i);return{fn:t,name:n,dependencies:o}},h={values:{$q:u,Array:e,is_array:n,Injector:c,"object.keys":r,"object.assign":t,make_injectable:p,"sorts.topological":o},definitions:{$q:f,Array:f,is_array:f,Injector:f,"object.keys":f,"object.assign":f,make_injectable:f,"sorts.topological":f}},l=function(n,r,s){function d(){var e=arguments[0],r=p.apply(null,arguments);return w.hasOwnProperty(e)&&i("'"+e+"' extends already registered in '"+n+"' module."),P[_++]=r,f(w,r),w}function f(n,r){var t=new e(r.dependencies.length);u.for_each_async(r.dependencies,function(e,n,r){E.resolve(e).then(function(e){t[n]=e,r()})}).then(function(){n[r.name]=r.fn.apply(n,t)})}var l,y,v,w={name:n,extend:d},O=new c,P=[],_=0,g={},E=new a(n,O,h,g),m=[];for(y=o(n,function(e){return s[e]?s[e].requires:n===e?r:void i("'"+e+"' module is not found.")}),v=y.length>1?new e(y.length-1):[],l=0;l<v.length;++l)m=m.concat(s[y[l]].extenders),t(O.definitions,s[y[l]].new_definitions);for(s[n]={name:n,requires:r,instance:w,injector:O,extenders:P,public_injector:E,new_definitions:g},l=0;l<m.length;++l)f(w,m[l]);return w},y=function(){};return y.prototype={use:function(e){return e(this),this}},{create:function(){function e(e,t){return n(t)?(r.hasOwnProperty(e)&&i("Duplicated module '"+e+"' is detected."),l(e,t,r)):(r.hasOwnProperty(e)||i("'"+e+"' module is not found."),r[e].instance)}var r={},t=new y;return t.module=e,t}}}(); | ||
"use strict";module.exports=function(){var e=Array,n=e.isArray,r=Object.keys,t=function(e){for(var n,t,i,o=1;o<arguments.length;++o)if(n=arguments[o])for(t=r(n),i=t.length-1;i>=0;e[t[i]]=n[t[i]],--i);return e},i=function(e){throw new Error(e)},o=function(n,r){var t=[],o={};return function s(u,c){for(var d=c.length-1,f=new e(d+1),a=r(u);d>=0;f[d]=c[d],--d);for(f.push(u),o[u]=!0,d=0;d<a.length;++d)f.indexOf(a[d])>=0&&i("Circular dependency '"+a[d]+" is required by '"+n+"' : "+f.join(" -> ")),o.hasOwnProperty(a[d])||s(a[d],f);-1===t.indexOf(u)&&t.push(u)}(n,[]),t},s=function(e){function n(){return 0===i}function r(e,n){return new s(function(r,s){switch(i){case 1:return r(e(t));case 2:return s(n(t));default:o[c]=e,o[c+1]=n,o[c+2]=r,o[c+3]=s,c+=4}})}var t,i=0,o=[],u=this,c=0;return u.then=r,u.state="pending...",u.is_pending=n,e(function(e){if(0===i){i=1,u.state="resolved",u.value=t=e;for(var n=0;n<c;n+=4)e=o[n](t),e&&"JEEFO_PROMISE"===e.type?e.then(o[n+2],o[n+3]):o[n+2](e);o=null,c=0}},function(e){if(0===i){i=2,u.state="rejected",u.reason=t=e;for(var n=1;n<c;n+=4)e=o[n](t),e&&"JEEFO_PROMISE"===e.type?e.then(o[n+1],o[n+2]):o[n+2](e);o=null,c=0}}),u};s.prototype.type="JEEFO_PROMISE";var u={defer:function(){var e={};return e.promise=new s(function(n,r){e.resolve=n,e.reject=r}),e},when:function(e){return e&&"JEEFO_PROMISE"===e.type?e:new s(function(n){n(e)})},for_each_async:function(e,n){function r(){++t<e.length?n.call(e,e[t],t,r,e):i.resolve()}var t=-1,i=this.defer();return r(),i.promise},all:function(e){for(var n,r=0,t=this.defer(),i=0;r<e.length;++r)(n=e[r])&&"JEEFO_PROMISE"===n.type&&(i+=1,n.then(function(n){return function(r){e[n]=r,0===--i&&t.resolve(e)}}(r)));return 0===i&&t.resolve(e),t.promise}},c=function(e){this.values=t({},e),this.definitions={}},d=[];c.prototype={register:function(n,r){if(r.dependencies){for(var t=new e(r.dependencies.length),o=t.length-1;o>=0;t[o]=r.dependencies[o],--o);(this.values.hasOwnProperty(n)||this.definitions.hasOwnProperty(n))&&i("Duplicated provider "+n+" detected."),this.definitions[n]={fn:r.fn,dependencies:t,is_constructor:!!r.is_constructor}}else this.definitions[n]={fn:r.fn,dependencies:d,is_constructor:!!r.is_constructor};return this},resolve:function(n,r){var t,s=this.values,c=this.definitions,d=r&&r.values||{},f=r&&r.definitions;return d.hasOwnProperty(n)?d[n]&&"JEEFO_PROMISE"===d[n].type?d[n]:u.when(d[n]):s.hasOwnProperty(n)?s[n]&&"JEEFO_PROMISE"===s[n].type?s[n]:u.when(s[n]):(t=o(n,function(e){return f&&f.hasOwnProperty(e)?f[e].dependencies:c.hasOwnProperty(e)?c[e].dependencies:void i("Injector '"+e+"' definition is not found.")}),u.for_each_async(t,function(n,r,t){var o,u;if(d.hasOwnProperty(n)||s.hasOwnProperty(n))return t();f&&f.hasOwnProperty(n)?(o=d,u=f[n]):(o=s,u=c[n]);for(var a=u.dependencies.length-1,p=new e(a+1);a>=0;--a)d.hasOwnProperty(u.dependencies[a])?p[a]=d[u.dependencies[a]]:s.hasOwnProperty(u.dependencies[a])?p[a]=s[u.dependencies[a]]:i("OMG");var h=u.fn.apply(null,p);u.is_constructor&&(h=new h),h&&"JEEFO_PROMISE"===h.type?h.then(function(e){o[n]=e,t()}):(o[n]=h,t())}).then(function(){return d.hasOwnProperty(n)?d[n]:s[n]}))},resolve_sync:function(n,r){var t,s=this,u=s.values,c=r&&r.values||{},d=s.definitions,f=r&&r.definitions;if(c.hasOwnProperty(n))return c[n];if(u.hasOwnProperty(n))return u[n];f&&f.hasOwnProperty(n)?t=c:d.hasOwnProperty(n)&&(t=u);for(var a=o(n,function(e){return f&&f.hasOwnProperty(e)?f[e].dependencies:d.hasOwnProperty(e)?d[e].dependencies:void i("Injector '"+e+"' definition is not found.")}),p=d[a.pop()],h=new e(p.dependencies.length),l=0;l<a.length;++l)c.hasOwnProperty(a[l])||u.hasOwnProperty(a[l])||s.resolve_sync(a[l],r);for(l=h.length-1;l>=0;--l)h[l]=c.hasOwnProperty(p.dependencies[l])?c[p.dependencies[l]]:u[p.dependencies[l]];return t[n]=p.fn.apply(null,h)}};var f=function(e,n,r,t){function o(e){return"$injector"===e||p.hasOwnProperty(e)||a.hasOwnProperty(e)}function s(r,s){return o(r)&&i("Duplicated provider '"+r+"' detected in module '"+e+"'."),n.register(r,s),t[r]=n.definitions[r],f}function c(t){return p.hasOwnProperty(t)?u.when(p[t]):a.hasOwnProperty(t)?n.resolve(t,r):void i("Module provider '"+t+"' definition is not found in '"+e+"' module.")}function d(t){return p.hasOwnProperty(t)?p[t]:a.hasOwnProperty(t)?n.resolve_sync(t,r):void i("Module provider '"+t+"' definition is not found in '"+e+"' module.")}var f=this,a=n.definitions,p=r.values;return f.has=o,f.resolve=c,f.register=s,f.resolve_sync=d,f},a={dependencies:d},p=function(n,r,t){if("function"===typeof r)return{fn:r,name:n,dependencies:d};if("string"===typeof r)return{fn:t,name:n,dependencies:[r]};for(var i=r.length-1,o=new e(i+1);i>=0;o[i]=r[i],--i);return{fn:t,name:n,dependencies:o}},h={values:{$q:u,Array:e,is_array:n,Injector:c,"object.keys":r,"object.assign":t,make_injectable:p,"sorts.topological":o},definitions:{$q:a,Array:a,is_array:a,Injector:a,"object.keys":a,"object.assign":a,make_injectable:a,"sorts.topological":a}},l=function(n,r,s){function a(){return j}function l(){var e=arguments[0],r=p.apply(null,arguments);return P.hasOwnProperty(e)&&i("'"+e+"' extends already registered in '"+n+"' module."),g[E++]=r,y(P,r),P}function y(n,r){var t=new e(r.dependencies.length);u.for_each_async(r.dependencies,function(e,n,r){j.resolve(e).then(function(e){t[n]=e,r()})}).then(function(){n[r.name]=r.fn.apply(n,t)})}var v,w,O,P={name:n,extend:l},_=new c,g=[],E=0,m={},j=new f(n,_,h,m),I=[];for(w=o(n,function(e){return s[e]?s[e].requires:n===e?r:void i("'"+e+"' module is not found.")}),O=w.length>1?new e(w.length-1):[],v=0;v<O.length;++v)I=I.concat(s[w[v]].extenders),t(_.definitions,s[w[v]].new_definitions);for(_.definitions.$injector={fn:a,dependencies:d},s[n]={name:n,requires:r,instance:P,injector:_,extenders:g,public_injector:j,new_definitions:m},v=0;v<I.length;++v)y(P,I[v]);return P},y=function(){};return y.prototype={use:function(e){return e(this),this}},{create:function(){function e(e,t){return n(t)?(r.hasOwnProperty(e)&&i("Duplicated module '"+e+"' is detected."),l(e,t,r)):(r.hasOwnProperty(e)||i("'"+e+"' module is not found."),r[e].instance)}var r={},t=new y;return t.module=e,t}}}(); |
{ | ||
"name": "jeefo", | ||
"version": "0.0.18", | ||
"version": "0.0.19", | ||
"homepage": "https://github.com/je3f0o/jeefo", | ||
@@ -5,0 +5,0 @@ "copyright": "2016", |
/* -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. | ||
* File Name : module.js | ||
* Created at : 2016-09-01 | ||
* Updated at : 2017-05-10 | ||
* Updated at : 2017-06-30 | ||
* Author : jeefo | ||
@@ -10,19 +10,6 @@ * Purpose : | ||
//ignore:start | ||
"use strict"; | ||
/* globals -PP, -IS_FUNCTION, -IS_STRING, -IS_UNDEFINED */ | ||
/* globals empty_array */ | ||
/* exported module */ | ||
/* exported */ | ||
/* | ||
var PP = { | ||
define : function (name, definition) { return definition; } | ||
}; | ||
var ARRAY = Array; | ||
var IS_STRING = PP.define("IS_STRING" , function (x) { return typeof x === "string"; }, true); | ||
var IS_FUNCTION = PP.define("IS_FUNCTION" , function (x) { return typeof x === "function"; }, true); | ||
var IS_UNDEFINED = PP.define("IS_UNDEFINED" , function (x) { return typeof x === "undefined"; }, true); | ||
*/ | ||
var object_keys = Object.keys; | ||
@@ -59,3 +46,3 @@ | ||
if (has(name)) { | ||
min_error(`Duplicated provider '${ name }' detected in module '${ module.name }'.`); | ||
min_error(`Duplicated provider '${ name }' detected in module '${ module_name }'.`); | ||
} | ||
@@ -69,5 +56,3 @@ injector.register(name, definition); | ||
function resolve (name) { | ||
if (name === "$injector") { | ||
return $q.when(self); | ||
} else if (local_values.hasOwnProperty(name)) { | ||
if (local_values.hasOwnProperty(name)) { | ||
return $q.when(local_values[name]); | ||
@@ -82,5 +67,3 @@ } else if (definitions.hasOwnProperty(name)) { | ||
function resolve_sync (name) { | ||
if (name === "$injector") { | ||
return self; | ||
} else if (local_values.hasOwnProperty(name)) { | ||
if (local_values.hasOwnProperty(name)) { | ||
return local_values[name]; | ||
@@ -183,2 +166,6 @@ } else if (definitions.hasOwnProperty(name)) { | ||
} | ||
injector.definitions.$injector = { | ||
fn : return_public_injector, | ||
dependencies : empty_array, | ||
}; | ||
@@ -202,2 +189,4 @@ container[module_name] = { | ||
function return_public_injector () { return public_injector; } | ||
// Do not use $injector.register inside extend function. | ||
@@ -204,0 +193,0 @@ // Which can be called each inherited modules. |
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
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
146892
3821