diff options
-rw-r--r-- | Gruntfile.js | 10 | ||||
-rw-r--r-- | bower.json | 2 | ||||
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | scorpion-tests.js (renamed from injector-tests.js) | 30 | ||||
-rw-r--r-- | scorpion.js (renamed from injector.js) | 84 | ||||
-rw-r--r-- | scorpion.min.js (renamed from injector.min.js) | 2 |
6 files changed, 65 insertions, 65 deletions
diff --git a/Gruntfile.js b/Gruntfile.js index e2febff..4710066 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -32,8 +32,8 @@ module.exports = function (grunt) { }, test: { files: [ - "injector.js", - "injector-tests.js" + "scorpion.js", + "scorpion-tests.js" ], tasks: ['test'] } @@ -45,14 +45,14 @@ module.exports = function (grunt) { reporter: 'min', require: [ function(){ - Injector = require('./injector'); + Scorpion = require('./scorpion'); expect = require('chai').expect; } ] }, src: [ - "injector.js", - "injector-tests.js" + "scorpion.js", + "scorpion-tests.js" ] } } @@ -1,5 +1,5 @@ { - "name": "injector", + "name": "scorpion", "version": "0.1.0" } diff --git a/package.json b/package.json index 2ff7b5b..f8e06b2 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "injector", + "name": "scorpion", "version": "0.1.0", "dependencies": {}, "devDependencies": { diff --git a/injector-tests.js b/scorpion-tests.js index e94126f..0bbe721 100644 --- a/injector-tests.js +++ b/scorpion-tests.js @@ -1,9 +1,9 @@ -/*global describe,it,expect,beforeEach,Injector, setTimeout*/ +/*global describe,it,expect,beforeEach,Scorpion, setTimeout*/ describe("deferred", function() { var deferred, promise; beforeEach(function() { - deferred = Injector.defer(); + deferred = Scorpion.defer(); promise = deferred.promise; }); this.timeout(100); @@ -93,7 +93,7 @@ describe("deferred", function() { it("should handle a returned promise by 'unwrapping' it", function(done) { promise.then(function(value) { - var deferred = Injector.defer(); + var deferred = Scorpion.defer(); deferred.resolve(value + 1); return deferred.promise; }).then(function(value) { @@ -177,7 +177,7 @@ describe("deferred", function() { it("should handle a returned promise by 'unwrapping' in the error case", function(done) { promise.then(function(value) { - var deferred = Injector.defer(); + var deferred = Scorpion.defer(); deferred.reject(value + 1); return deferred.promise; }).then(null, function(value) { @@ -194,10 +194,10 @@ describe("deferred", function() { describe("waitForAll", function() { it("should resolve with an array if all successful", function(done) { - var d1 = Injector.defer(), - d2 = Injector.defer(), - d3 = Injector.defer(); - Injector + var d1 = Scorpion.defer(), + d2 = Scorpion.defer(), + d3 = Scorpion.defer(); + Scorpion .waitForAll([d1.promise, d2.promise, d3.promise]) .then(function(values) { if (values.length == 3 && @@ -215,10 +215,10 @@ describe("deferred", function() { }); it("should reject with an object of successes/errors if any fail", function(done) { - var d1 = Injector.defer(), - d2 = Injector.defer(), - d3 = Injector.defer(); - Injector + var d1 = Scorpion.defer(), + d2 = Scorpion.defer(), + d3 = Scorpion.defer(); + Scorpion .waitForAll([d1.promise, d2.promise, d3.promise]) .then(function(values) { done(new Error("incorrectly resolved promise")); @@ -242,8 +242,8 @@ describe("deferred", function() { describe("injector", function() { var injector, valuePlugin; beforeEach(function() { - valuePlugin = new Injector.ValuePlugin(); - injector = new Injector([valuePlugin]); + valuePlugin = new Scorpion.ValuePlugin(); + injector = new Scorpion([valuePlugin]); }); this.timeout(100); @@ -337,7 +337,7 @@ describe("injector", function() { describe("cyclic dependency detection", function() { it("detects simple cycles", function(done) { injector.register("a", ["b", function(b) {return b;}]); - injector.register("b", ["a", function(a) {return a;}]); + injector.register("b", ["a", function(a) {return a;}]); injector.get("a").then(function() { done(new Error("Promise should have been rejected")); }, function(e) { diff --git a/injector.js b/scorpion.js index e644539..6d7051c 100644 --- a/injector.js +++ b/scorpion.js @@ -1,6 +1,6 @@ /*global module, setTimeout*/ -var Injector = (function() { +var Scorpion = (function() { var Deferred = (function() { var defer = function(fn, value) {setTimeout(function() {fn(value);});}; @@ -28,11 +28,11 @@ var Injector = (function() { this.rejected = false; this.onSuccess = []; this.onError = []; - }; + }; Promise.prototype.then = function(success, error) { success = success || function(x) {return x;}; error = error || function(x) {throw x;}; - var deferred = new Deferred(); + var deferred = new Deferred(); var successFn = runFn(success, deferred); var errorFn = runFn(error, deferred); if (this.resolved) { @@ -148,7 +148,7 @@ var Injector = (function() { }; var parseDep = function(dep) { - var parts = dep.split("!"); + var parts = dep.split("!"); if (parts.length == 0) { throw new Error("Invalid dependency: " + dep); } else if (parts.length == 1) { @@ -164,28 +164,28 @@ var Injector = (function() { }; })(); - var Injector = (function(Deferred, DepsParser) { + var Scorpion = (function(Deferred, DepsParser) { - var Injector = function(plugins) { + var Scorpion = function(plugins) { // plugins are a list to be executed in order this.plugins = plugins; }; - Injector.rejected = function(message, cause) { + Scorpion.rejected = function(message, cause) { var deferred = this.defer(); deferred.reject(this.error(message, cause)); return deferred.promise; }; - Injector.prototype.rejected = Injector.rejected; + Scorpion.prototype.rejected = Scorpion.rejected; - Injector.resolved = function(value) { + Scorpion.resolved = function(value) { var deferred = this.defer(); deferred.resolve(value); return deferred.promise; }; - Injector.prototype.resolved = Injector.resolved; + Scorpion.prototype.resolved = Scorpion.resolved; - Injector.prototype.get = function(dep, stack) { + Scorpion.prototype.get = function(dep, stack) { stack = [dep].concat(stack || []); if (stack && stack.lastIndexOf(dep) != 0) { return this.rejected("Cyclic dependency: " + stack.join(" <- ")); @@ -194,14 +194,14 @@ var Injector = (function() { var value = this.plugins[i].get(this, dep, stack); if (value) { if (!value.destroy) - value.destroy = function(){return Injector.resolved(true);}; + value.destroy = function(){return Scorpion.resolved(true);}; return value; } } return this.rejected("Unknown dependency: " + stack.join(" <- ")); }; - Injector.prototype.register = function(name, value) { + Scorpion.prototype.register = function(name, value) { for (var i = 0, l = this.plugins.length; i < l; ++i) { if (this.plugins[i].register(this, name, value)) return this; @@ -210,7 +210,7 @@ var Injector = (function() { return this; }; - Injector.prototype.invoke = function(spec) { + Scorpion.prototype.invoke = function(spec) { var injector = this; var parsed = this.parseSpec(spec); var fn = parsed[0]; @@ -223,7 +223,7 @@ var Injector = (function() { return fn.apply(injector, results); }); result.destroy = function() { - return Injector.waitForAll(depPromises.map(function(promise) { + return Scorpion.waitForAll(depPromises.map(function(promise) { return promise.destroy(); })).then(function() { return true; @@ -236,36 +236,36 @@ var Injector = (function() { /* static utility functions */ - Injector.error = function(message, cause) {return new InjectorError(message, cause);}; - Injector.prototype.error = Injector.error; + Scorpion.error = function(message, cause) {return new ScorpionError(message, cause);}; + Scorpion.prototype.error = Scorpion.error; - Injector.defer = function() {return new Deferred();}; - Injector.prototype.defer = Injector.defer; + Scorpion.defer = function() {return new Deferred();}; + Scorpion.prototype.defer = Scorpion.defer; - Injector.parseSpec = DepsParser.spec; - Injector.prototype.parseSpec = DepsParser.spec; + Scorpion.parseSpec = DepsParser.spec; + Scorpion.prototype.parseSpec = DepsParser.spec; - Injector.waitForAll = Deferred.waitForAll; - Injector.prototype.waitForAll = Deferred.waitForAll; + Scorpion.waitForAll = Deferred.waitForAll; + Scorpion.prototype.waitForAll = Deferred.waitForAll; /* the injector error type */ - var InjectorError = function(message, cause) { - this.name = "InjectorError"; + var ScorpionError = function(message, cause) { + this.name = "ScorpionError"; this.message = message; this.cause = cause; }; - InjectorError.prototype = new Error(); - InjectorError.prototype.constructor = InjectorError; - InjectorError.prototype.toString = function() { - return "InjectorError: " + this.message + (this.cause ? " [caused by " + this.cause + "]" : ""); + ScorpionError.prototype = new Error(); + ScorpionError.prototype.constructor = ScorpionError; + ScorpionError.prototype.toString = function() { + return "ScorpionError: " + this.message + (this.cause ? " [caused by " + this.cause + "]" : ""); }; - return Injector; + return Scorpion; })(Deferred, DepsParser); - Injector.prefixPlugin = function(prefix, plugin) { + Scorpion.prefixPlugin = function(prefix, plugin) { return { register: function(injector, name, spec) { if (name.indexOf(prefix) == 0) { @@ -288,7 +288,7 @@ var Injector = (function() { }; }; - Injector.DOMPlugin = (function() { + Scorpion.DOMPlugin = (function() { var DOMPlugin = function() { this.aliases = {}; }; @@ -313,7 +313,7 @@ var Injector = (function() { return DOMPlugin; })(); - Injector.HTTPPlugin = (function() { + Scorpion.HTTPPlugin = (function() { var HTTPPlugin = function() { this.aliases = {}; }; @@ -330,7 +330,7 @@ var Injector = (function() { // deferred.resolve.bind(deferred); }, deferred.reject.bind(deferred)); deferred.promise.destroy = function() { - return Injector.resolved(true); + return Scorpion.resolved(true); }; return deferred.promise; }; @@ -338,7 +338,7 @@ var Injector = (function() { return HTTPPlugin; })(); - Injector.ValuePlugin = (function() { + Scorpion.ValuePlugin = (function() { var ValuePlugin = function() { this.specs = {}; this.values = {}; @@ -354,7 +354,7 @@ var Injector = (function() { this.values[name].references++; return this.values[name]; } else if (name in this.specs) { - var spec = this.specs[name]; + var spec = this.specs[name]; var parsed = injector.parseSpec(spec); var constructor = parsed[0]; var dependencies = parsed[1]; @@ -368,17 +368,17 @@ var Injector = (function() { var deferred = injector.defer(); var result = deferred.promise; depPromise.then(function(results) { - var wrappedInjector = Object.create(injector); - wrappedInjector.requestor = function() { + var wrappedScorpion = Object.create(injector); + wrappedScorpion.requestor = function() { readRequestor = true; return stack[1]; }; try { - deferred.resolve(constructor.apply(wrappedInjector, results)); + deferred.resolve(constructor.apply(wrappedScorpion, results)); } catch (e) { deferred.reject(e); } finally { - onDestroy = wrappedInjector.onDestroy; + onDestroy = wrappedScorpion.onDestroy; if (result.references <= 0 && onDestroy) onDestroy(); } @@ -419,8 +419,8 @@ var Injector = (function() { })(); - return Injector; + return Scorpion; })(); if (typeof(module) !== "undefined") - module.exports = Injector; + module.exports = Scorpion; diff --git a/injector.min.js b/scorpion.min.js index 2f09e0f..5524044 100644 --- a/injector.min.js +++ b/scorpion.min.js @@ -1 +1 @@ -/*! injector 0.1.0 */var Injector=function(){var a=function(){var a=function(a,b){setTimeout(function(){a(b)})},b=function(a,b){return function(c){try{var d=a(c);d&&d.then?d.then(function(a){b.resolve(a)},function(a){b.reject(a)}):b.resolve(d)}catch(e){b.reject(e)}}},c=function(){this.resolved=!1,this.rejected=!1,this.onSuccess=[],this.onError=[]};c.prototype.then=function(c,e){c=c||function(a){return a},e=e||function(a){throw a};var f=new d,g=b(c,f),h=b(e,f);return this.resolved?a(g,this.value):this.rejected?a(h,this.value):(null!=this.onSuccess&&this.onSuccess.push(g),null!=this.onError&&this.onError.push(h)),f.promise};var d=function(){this.promise=new c};return d.prototype.resolve=function(a){if(this.promise.resolved)throw new Error("Cannot re-resolve already resolved promise");if(this.promise.rejected)throw new Error("Cannot resolve a rejected promise");this.promise.resolved=!0,this.promise.value=a;var b=this.promise.onSuccess;this.promise.onSuccess=null,this.promise.onError=null,setTimeout(function(){b.forEach(function(b){b(a)})})},d.prototype.reject=function(a){if(this.promise.resolved)throw new Error("Cannot reject an already resolved promise");if(this.promise.rejected)throw new Error("Cannot re-reject a rejected promise");this.promise.rejected=!0,this.promise.value=a;var b=this.promise.onError;this.promise.onSuccess=null,this.promise.onError=null,setTimeout(function(){b.forEach(function(b){b(a)})})},d.waitForAll=function(a){var b=new d,c=0,e=0,f={},g={},h=a.length;a.forEach(function(a,b){a.then(function(a){g[b]=a,c++,i()},function(a){f[b]=a,e++,i()})});var i=function(){if(c==h){for(var a=[],d=0,i=h;i>d;++d)a.push(g[d]);b.resolve(a)}else c+e==h&&b.reject({errors:f,values:g})};return i(),b.promise},d}(),b=function(){var a=/^function[^(]*\(([^)]*)\)/,b=function(b){var c=a.exec(b.toString().replace(/\s+/g,""));if(null==c)throw new Error("Unable to parse fn definition");return c[1]?c[1].split(/,/):[]},c=function(a){var c,d;return"function"==typeof a||a instanceof Function?(d=b(a),c=a):(c=a[a.length-1],d=a.slice(0,a.length-1)),[c,d]},d=function(a){var b=a.split("!");if(0==b.length)throw new Error("Invalid dependency: "+a);return 1==b.length?{prefix:"",name:b[0]}:{prefix:b[0],name:b.slice(1).join("!")}};return{spec:c,dep:d}}(),c=function(a,b){var c=function(a){this.plugins=a};c.rejected=function(a,b){var c=this.defer();return c.reject(this.error(a,b)),c.promise},c.prototype.rejected=c.rejected,c.resolved=function(a){var b=this.defer();return b.resolve(a),b.promise},c.prototype.resolved=c.resolved,c.prototype.get=function(a,b){if(b=[a].concat(b||[]),b&&0!=b.lastIndexOf(a))return this.rejected("Cyclic dependency: "+b.join(" <- "));for(var d=0,e=this.plugins.length;e>d;++d){var f=this.plugins[d].get(this,a,b);if(f)return f.destroy||(f.destroy=function(){return c.resolved(!0)}),f}return this.rejected("Unknown dependency: "+b.join(" <- "))},c.prototype.register=function(a,b){for(var c=0,d=this.plugins.length;d>c;++c)if(this.plugins[c].register(this,a,b))return this;throw this.error("No plugin handled registration of: "+a)},c.prototype.invoke=function(a){var b=this,d=this.parseSpec(a),e=d[0],f=d[1],g=f.map(function(a){return b.get(a,[])}),h=this.waitForAll(g),i=h.then(function(a){return e.apply(b,a)});return i.destroy=function(){return c.waitForAll(g.map(function(a){return a.destroy()})).then(function(){return!0})},i},c.error=function(a,b){return new d(a,b)},c.prototype.error=c.error,c.defer=function(){return new a},c.prototype.defer=c.defer,c.parseSpec=b.spec,c.prototype.parseSpec=b.spec,c.waitForAll=a.waitForAll,c.prototype.waitForAll=a.waitForAll;var d=function(a,b){this.name="InjectorError",this.message=a,this.cause=b};return d.prototype=new Error,d.prototype.constructor=d,d.prototype.toString=function(){return"InjectorError: "+this.message+(this.cause?" [caused by "+this.cause+"]":"")},c}(a,b);return c.prefixPlugin=function(a,b){return{register:function(c,d,e){return 0==d.indexOf(a)?b.register(c,d.substr(a.length),e):!1},get:function(c,d,e){return 0==d.indexOf(a)?b.get(c,d.substr(a.length),e):null}}},c.DOMPlugin=function(){var a=function(){this.aliases={}};return a.prototype.register=function(a,b,c){return this.aliases[b]=c,!0},a.prototype.get=function(a,b){var c=a.defer(),d=setInterval(function(){var a=$(this.aliases[b]||b);a.length&&(clearInterval(d),c.resolve(a))}.bind(this),100);return c.promise},a}(),c.HTTPPlugin=function(){var a=function(){this.aliases={}};return a.prototype.register=function(a,b,c){return this.aliases[b]=c,!0},a.prototype.get=function(a,b){var d=a.defer();return $.ajax(this.aliases[b]||b).then(function(a){d.resolve(a)},d.reject.bind(d)),d.promise.destroy=function(){return c.resolved(!0)},d.promise},a}(),c.ValuePlugin=function(){var a=function(){this.specs={},this.values={}};return a.prototype.register=function(a,b,c){return this.specs[b]=c,!0},a.prototype.get=function(a,b,c){if(b in this.values)return this.values[b].references++,this.values[b];if(b in this.specs){var d=this.specs[b],e=a.parseSpec(d),f=e[0],g=e[1],h=g.map(function(d){return a.get(d,[b].concat(c))}),i=a.waitForAll(h),j=null,k=!1,l=a.defer(),m=l.promise;i.then(function(b){var d=Object.create(a);d.requestor=function(){return k=!0,c[1]};try{l.resolve(f.apply(d,b))}catch(e){l.reject(e)}finally{j=d.onDestroy,m.references<=0&&j&&j()}},function(){l.reject(a.error("Error constructing "+b))}),m.references=1;var n=this.values;return m.destroy=function(){return this.references--,this.references<=0?(j&&j(),delete n[b],m.resolved||m.rejected||l.reject(a.error("Promise destroyed before value completed construction")),a.waitForAll(h.map(function(a){return a.destroy()})).then(function(){return!0})):a.resolved(!0)},k?m:this.values[b]=m}return null},a}(),c}();"undefined"!=typeof module&&(module.exports=Injector);
\ No newline at end of file +/*! scorpion 0.1.0 */var Scorpion=function(){var a=function(){var a=function(a,b){setTimeout(function(){a(b)})},b=function(a,b){return function(c){try{var d=a(c);d&&d.then?d.then(function(a){b.resolve(a)},function(a){b.reject(a)}):b.resolve(d)}catch(e){b.reject(e)}}},c=function(){this.resolved=!1,this.rejected=!1,this.onSuccess=[],this.onError=[]};c.prototype.then=function(c,e){c=c||function(a){return a},e=e||function(a){throw a};var f=new d,g=b(c,f),h=b(e,f);return this.resolved?a(g,this.value):this.rejected?a(h,this.value):(null!=this.onSuccess&&this.onSuccess.push(g),null!=this.onError&&this.onError.push(h)),f.promise};var d=function(){this.promise=new c};return d.prototype.resolve=function(a){if(this.promise.resolved)throw new Error("Cannot re-resolve already resolved promise");if(this.promise.rejected)throw new Error("Cannot resolve a rejected promise");this.promise.resolved=!0,this.promise.value=a;var b=this.promise.onSuccess;this.promise.onSuccess=null,this.promise.onError=null,setTimeout(function(){b.forEach(function(b){b(a)})})},d.prototype.reject=function(a){if(this.promise.resolved)throw new Error("Cannot reject an already resolved promise");if(this.promise.rejected)throw new Error("Cannot re-reject a rejected promise");this.promise.rejected=!0,this.promise.value=a;var b=this.promise.onError;this.promise.onSuccess=null,this.promise.onError=null,setTimeout(function(){b.forEach(function(b){b(a)})})},d.waitForAll=function(a){var b=new d,c=0,e=0,f={},g={},h=a.length;a.forEach(function(a,b){a.then(function(a){g[b]=a,c++,i()},function(a){f[b]=a,e++,i()})});var i=function(){if(c==h){for(var a=[],d=0,i=h;i>d;++d)a.push(g[d]);b.resolve(a)}else c+e==h&&b.reject({errors:f,values:g})};return i(),b.promise},d}(),b=function(){var a=/^function[^(]*\(([^)]*)\)/,b=function(b){var c=a.exec(b.toString().replace(/\s+/g,""));if(null==c)throw new Error("Unable to parse fn definition");return c[1]?c[1].split(/,/):[]},c=function(a){var c,d;return"function"==typeof a||a instanceof Function?(d=b(a),c=a):(c=a[a.length-1],d=a.slice(0,a.length-1)),[c,d]},d=function(a){var b=a.split("!");if(0==b.length)throw new Error("Invalid dependency: "+a);return 1==b.length?{prefix:"",name:b[0]}:{prefix:b[0],name:b.slice(1).join("!")}};return{spec:c,dep:d}}(),c=function(a,b){var c=function(a){this.plugins=a};c.rejected=function(a,b){var c=this.defer();return c.reject(this.error(a,b)),c.promise},c.prototype.rejected=c.rejected,c.resolved=function(a){var b=this.defer();return b.resolve(a),b.promise},c.prototype.resolved=c.resolved,c.prototype.get=function(a,b){if(b=[a].concat(b||[]),b&&0!=b.lastIndexOf(a))return this.rejected("Cyclic dependency: "+b.join(" <- "));for(var d=0,e=this.plugins.length;e>d;++d){var f=this.plugins[d].get(this,a,b);if(f)return f.destroy||(f.destroy=function(){return c.resolved(!0)}),f}return this.rejected("Unknown dependency: "+b.join(" <- "))},c.prototype.register=function(a,b){for(var c=0,d=this.plugins.length;d>c;++c)if(this.plugins[c].register(this,a,b))return this;throw this.error("No plugin handled registration of: "+a)},c.prototype.invoke=function(a){var b=this,d=this.parseSpec(a),e=d[0],f=d[1],g=f.map(function(a){return b.get(a,[])}),h=this.waitForAll(g),i=h.then(function(a){return e.apply(b,a)});return i.destroy=function(){return c.waitForAll(g.map(function(a){return a.destroy()})).then(function(){return!0})},i},c.error=function(a,b){return new d(a,b)},c.prototype.error=c.error,c.defer=function(){return new a},c.prototype.defer=c.defer,c.parseSpec=b.spec,c.prototype.parseSpec=b.spec,c.waitForAll=a.waitForAll,c.prototype.waitForAll=a.waitForAll;var d=function(a,b){this.name="InjectorError",this.message=a,this.cause=b};return d.prototype=new Error,d.prototype.constructor=d,d.prototype.toString=function(){return"InjectorError: "+this.message+(this.cause?" [caused by "+this.cause+"]":"")},c}(a,b);return c.prefixPlugin=function(a,b){return{register:function(c,d,e){return 0==d.indexOf(a)?b.register(c,d.substr(a.length),e):!1},get:function(c,d,e){return 0==d.indexOf(a)?b.get(c,d.substr(a.length),e):null}}},c.DOMPlugin=function(){var a=function(){this.aliases={}};return a.prototype.register=function(a,b,c){return this.aliases[b]=c,!0},a.prototype.get=function(a,b){var c=a.defer(),d=setInterval(function(){var a=$(this.aliases[b]||b);a.length&&(clearInterval(d),c.resolve(a))}.bind(this),100);return c.promise},a}(),c.HTTPPlugin=function(){var a=function(){this.aliases={}};return a.prototype.register=function(a,b,c){return this.aliases[b]=c,!0},a.prototype.get=function(a,b){var d=a.defer();return $.ajax(this.aliases[b]||b).then(function(a){d.resolve(a)},d.reject.bind(d)),d.promise.destroy=function(){return c.resolved(!0)},d.promise},a}(),c.ValuePlugin=function(){var a=function(){this.specs={},this.values={}};return a.prototype.register=function(a,b,c){return this.specs[b]=c,!0},a.prototype.get=function(a,b,c){if(b in this.values)return this.values[b].references++,this.values[b];if(b in this.specs){var d=this.specs[b],e=a.parseSpec(d),f=e[0],g=e[1],h=g.map(function(d){return a.get(d,[b].concat(c))}),i=a.waitForAll(h),j=null,k=!1,l=a.defer(),m=l.promise;i.then(function(b){var d=Object.create(a);d.requestor=function(){return k=!0,c[1]};try{l.resolve(f.apply(d,b))}catch(e){l.reject(e)}finally{j=d.onDestroy,m.references<=0&&j&&j()}},function(){l.reject(a.error("Error constructing "+b))}),m.references=1;var n=this.values;return m.destroy=function(){return this.references--,this.references<=0?(j&&j(),delete n[b],m.resolved||m.rejected||l.reject(a.error("Promise destroyed before value completed construction")),a.waitForAll(h.map(function(a){return a.destroy()})).then(function(){return!0})):a.resolved(!0)},k?m:this.values[b]=m}return null},a}(),c}();"undefined"!=typeof module&&(module.exports=Scorpion);
\ No newline at end of file |