Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

esquire

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esquire - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

2

esquire-full.min.js

@@ -1,1 +0,1 @@

"use strict";!function a(b){function c(a,b){if(!(this instanceof c))return new c(a,b);var d=0,e=null,f=[],g=function(a){var b=d>0?"resolve":0>d?"reject":null;if(b)for(var c in a)a[c][b](e)},h=this;Object.defineProperties(this,{resolve:{enumerable:!0,configurable:!1,value:function(b){if(b&&"function"==typeof b.then)b.then(function(a){h.resolve(a)},function(a){h.reject(a)});else if(0==d){if(e=b,d=1,a)try{e=a(e)}catch(c){e=c,d=-1}g(f)}}},reject:{enumerable:!0,configurable:!1,value:function(a){if(0==d){if(e=a,d=-1,b)try{e=b(e),d=1}catch(c){e=c}g(f)}}},promise:{enumerable:!0,configurable:!1,value:Object.defineProperties(new Object,{then:{enumerable:!0,configurable:!1,value:function(a,b){var e=new c(a,b);return 0==d?f.push(e):g([e]),e.promise}},"catch":{enumerable:!0,configurable:!1,value:function(a){return this.then(null,a)}}})}})}function d(a){if(!(this instanceof d))return new d(a);if("function"!=typeof a)throw new TypeError("Executor is not a function");var b=new c;Object.defineProperty(this,"then",{enumerable:!0,configurable:!1,value:b.promise.then}),Object.defineProperty(this,"catch",{enumerable:!0,configurable:!1,value:b.promise["catch"]});try{a(b.resolve,b.reject)}catch(e){b.reject(e)}}function e(a,b){a="Esquire: "+(a||"Unknown error");var c="";if(b&&b.length)for(var d=0;d<b.length;d++)b[d]&&(c+=" -> "+b[d]);if(c&&(a+=" resolving"+c),Error.call(this,a),this.message=a,this.stack){var e=this.stack;e=e.replace(new RegExp("^"+this.name+"\n"),""),this.stack=this.name+": "+this.message+"\n"+e}}function f(a,b){e.call(this,"Module '"+a+"' not found",b)}function g(a,b,c){e.call(this,"Module '"+a+"' failed to initialize",c),b&&(this.message=this.message+" [Cause: "+(b.message?b.message:"[no message]")+"]",this.cause=b)}function h(a,b){e.call(this,"Module '"+a+"' has circular dependencies",b)}function i(a,b,c,d){a=o(a);for(var e in b)b[e]=o(b[e]);Object.defineProperty(this,"name",{enumerable:!0,configurable:!1,value:a}),Object.defineProperty(this,"dependencies",{enumerable:!0,configurable:!1,value:b}),Object.defineProperty(this,"constructor",{enumerable:!0,configurable:!1,value:c}),Object.defineProperty(this,"$$dynamic",{enumerable:!1,configurable:!1,value:d||!1}),Object.defineProperty(this,"$$script",{enumerable:!1,configurable:!1,get:function(){return"Esquire.define("+JSON.stringify(this.name)+","+JSON.stringify(this.dependencies)+","+c.toString()+");"}}),Object.freeze(this)}function j(a){i.call(this,a,["$global"],function(a){function b(a,c,d){if(!d&&a in c)return c[a];var e=["Ms","ms","Moz","moz","WebKit","webkit"];for(var f in e){var g=e[f]+a;if(g in c)return c[g]}return a[0]!==a[0].toUpperCase()?b(a[0].toUpperCase()+a.substring(1),c,!0):void 0}function c(a,d){if(!d)return void 0;if(!a)return void 0;switch(a.length){case 0:return void 0;case 1:return b(a[0],d);default:return c(a.slice(1),b(a[0],d))}}return c(this.name.substring(8).split("."),a)},!0)}function k(a){i.call(this,a,[],function(){throw new e("The constructor for '"+a+"' should not be called'")},!0)}function l(a){if(!a)return[];for(var b=[],c=0;c<a.length;c++){var d=a[c];if("string"==typeof d)b.push(d);else if("function"==typeof d)b.push(d);else if(Array.isArray(d))b=b.concat(l(d));else{if("object"!=typeof d||"number"!=typeof d.length)throw new e("Invalid dependency: "+JSON.stringify(d));b=b.concat(l(d))}}return b}function m(){var a=l(arguments),b={arguments:[],"function":null};if(!a.length)return b;"function"==typeof a[a.length-1]&&(b.function=a.splice(-1)[0]);for(var c in a){var d=a[c];if("string"!=typeof d)throw new e("Found "+typeof d+" but needed string: "+d);b.arguments.push(d)}return b}function n(a){return/^\$global[\/\.].+/.test(a)}function o(a){return n(a)?"$global/"+a.substring(8):a}function p(){if(1==arguments.length&&arguments[0].name&&arguments[0].constructor){var a=arguments[0];return p(a.name,a.dependencies||[],a.constructor)}var b,c,d=m(arguments),f=[];if(!d.arguments.length)throw new e("No module name specified");if(b=o(d.arguments.splice(0,1)[0]),f=d.arguments,s[b])throw new e("Module '"+b+"' already defined");if(!d.function)throw new e("No constructor function specified for module '"+b+"'");return c=d.function,s[b]=new i(b,f,c),s[b]}function q(a,b,c){if(c||(c=[]),!a)throw new e("No module or module name specified");if("string"==typeof a){if(!s[a])throw new f(m,c);a=s[a]}if(c.indexOf(a.name)>=0)throw new h(a.name,c);var d=[];c.push(a.name);for(var g in a.dependencies){var i=a.dependencies[g],k=s[i];if(k){if(d.push(k),b){var l=q(k,c);for(var m in l)d.push(l[m])}}else{if(!n(i))throw new f(a.dependencies[g],c);d.push(new j(i))}}return c.pop(),d}function r(a){function f(c,d){if(l[c.name])return l[c.name];var h=q(c,!1,d),i=[];for(var j in h){var m=h[j];l[m.name]?i.push(l[m.name]):(d.push(c.name),i.push(f(m,d)),d.pop())}var n=d.slice(0),o=new k(function(f,h){var j=a-10*d.length,l=b.setTimeout(function(){h(new e("Timeout reached waiting for module '"+c.name+"'",n))},50>j?50:j),m=function(a){b.clearTimeout(l),f(a)},o=function(a){b.clearTimeout(l),h(a)};k.all(i).then(function(a){try{var b=c.constructor.apply(c,a);k.resolve(b).then(function(a){m(a)},function(a){o(new g(c.name,a,n)),o(a)})}catch(d){o(new g(c.name,d,n))}},function(a){o(a)})});return c.name&&!c.$$dynamic&&(l[c.name]=o),o}function h(){return 1==arguments.length&&"string"==typeof arguments[0]?j([arguments[0]],function(a){return a}):j(arguments,function(){for(var a=[],b=0;b<arguments.length;b++)a.push(arguments[b]);return a})}function j(){var a=m(arguments);if(!a.function)throw new e("Callback for injection unspecified");var b=new i(null,a.arguments,a.function);try{return f(b,[])}catch(c){return k.reject(c)}}if(!(this instanceof r))return new r(k);var k=b.Promise||d;if(void 0===a)a=2e3;else{if(a=Number(a),0/0===a)throw new e("Timeout is not a number");if(100>a)throw new e("Timeout must be greater or equal than 100ms")}var l={$global:b,$esquire:this,$promise:k,$deferred:c};Object.defineProperties(this,{inject:{enumerable:!0,configurable:!1,value:j},require:{enumerable:!0,configurable:!1,value:h}})}c.prototype=Object.create(Object.prototype),c.prototype.constructor=c,c.prototype.name="Deferred",d.prototype=Object.create(Object.prototype),d.prototype.constructor=d,d.prototype.name="Promise",Object.defineProperty(d,"all",{enumerable:!0,configurable:!1,value:function(a){if(!Array.isArray(a))return d.reject(new TypeError("Invalid argument"));var b=[];for(var e in a)b.push(d.resolve(a[e]));if(0==b.length)return d.resolve([]);for(var f=new c,g=new Array(b.length),h=b.length,e=0;e<b.length;e++)!function(a){b[a].then(function(b){g[a]=b,0==--h&&f.resolve(g)},function(a){f.reject(a)})}(e);return f.promise}}),Object.defineProperty(d,"race",{enumerable:!0,configurable:!1,value:function(a){if(!Array.isArray(a))return d.reject(new TypeError("Invalid argument"));var b=new c;for(var e in a)d.resolve(a[e]).then(function(a){b.resolve(a)},function(a){b.reject(a)});return b.promise}}),Object.defineProperty(d,"resolve",{enumerable:!0,configurable:!1,value:function(a){return new d(function(b,c){a&&a.then&&"function"==typeof a.then?a.then(b,c):b(a)},!0)}}),Object.defineProperty(d,"reject",{enumerable:!0,configurable:!1,value:function(a){return new d(function(b,c){c(a)},!0)}}),e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.prototype.name="EsquireError",f.prototype=Object.create(e.prototype),f.prototype.constructor=f,f.prototype.name="NoModuleError",g.prototype=Object.create(e.prototype),g.prototype.constructor=g,g.prototype.name="ModuleConstructorError",h.prototype=Object.create(e.prototype),h.prototype.constructor=h,h.prototype.name="CircularDependencyError",j.prototype=Object.create(i.prototype),j.prototype.constructor=j,j.prototype.name="GlobalModule",k.prototype=Object.create(i.prototype),k.prototype.constructor=k,k.prototype.name="InternalModule";var s={$global:new k("$global"),$esquire:new k("$esquire"),$promise:new k("$promise"),$deferred:new k("$deferred")};if(Object.defineProperties(r,{$$script:{enumerable:!1,configurable:!1,value:a.toString()},$$normalize:{enumerable:!1,configurable:!1,value:m},$$Promise:{enumerable:!1,configurable:!1,value:d},$$Deferred:{enumerable:!1,configurable:!1,value:c},define:{enumerable:!0,configurable:!1,value:p},resolve:{enumerable:!0,configurable:!1,value:q},modules:{enumerable:!0,configurable:!1,get:function(){var a={};for(var b in s)a[b]=s[b];return Object.freeze(a)}},module:{enumerable:!0,configurable:!1,value:function(a){return a=o(a),a in s?s[a]:n(a)?new j(a):null}}}),b.Esquire)throw new Error("Esquire already defined in global scope");b.Esquire=r;var t=new r;b.esquire=function(){if(0==arguments.length)throw new e("No dependencies/callback specified");var a=m(arguments);return a.function?t.inject(a.arguments,a.function):t.require(1==arguments.length&&"string"==typeof arguments[0]?arguments[0]:a.arguments)}}(function(){try{return window}catch(a){return global}}()),function(a){function b(a){var b=a.filename||a.target&&a.target.src;if(g[b]){if(a.stopPropagation&&a.stopPropagation(),a.preventDefault&&a.preventDefault(),a.target&&a.target.parentNode)try{a.target.parentNode.removeChild(a.target)}catch(c){}var d=g[b];return delete g[b],d.remaining-=1,{script:b,promise:d}}}function c(a){var c=b(a);c&&(console.debug("Esquire: Successfully loaded script '",c.script,"'"),0==c.promise.remaining&&c.promise.resolve(Esquire.modules))}function d(a){var c=b(a);if(c){console.warn("Esquire: Unable to load script '",c.script,"'");var d=a.error||new Error("Unable to load script '"+c.script+"'");c.promise.reject(d)}}function e(){if(!h)throw new Error("Esquire: Document not available");var a=h.getElementsByTagName("script")[0],b=a.parentNode,e=new Esquire.$$Deferred(function(a){return a},function(a){throw a});e.remaining=0;var i=Esquire.$$normalize(arguments).arguments,j=[];for(var k in i)!function(a){var b=h.createElement("script");b.async=!0,b.defer=!0,b.src=a,a=b.src,f[a]?console.debug("Esquire: Script '"+a+"' already loaded"):g[a]?console.debug("Esquire: Script '"+a+"' already being loaded"):(b.addEventListener("load",c,!1),b.addEventListener("error",d,!1),g[a]=e,e.remaining+=1,j.push(b))}(i[k]);if(0==j.length)e.resolve(Esquire.modules);else for(var k in j)console.debug("Esquire: About to load '"+j[k].src+"'"),b.insertBefore(j[k],a);return e.promise}if(!a.Esquire)throw new Error("Esquire not available");var f={},g={};a.addEventListener("error",d,!0);var h=a.document;a.Esquire||(a.Esquire={}),a.Esquire.load=e}(window);
"use strict";!function a(b){function c(a,b){if(!(this instanceof c))return new c(a,b);var d=0,e=null,f=[],g=function(a){var b=d>0?"resolve":0>d?"reject":null;if(b)for(var c in a)a[c][b](e)},h=this;Object.defineProperties(this,{$$id:{enumerable:!1,configurable:!1,value:++s},resolve:{enumerable:!0,configurable:!1,value:function(b){if(b&&"function"==typeof b.then)b.then(function(a){h.resolve(a)},function(a){h.reject(a)});else if(0==d){if(e=b,d=1,a)try{e=a(e)}catch(c){e=c,d=-1}g(f)}}},reject:{enumerable:!0,configurable:!1,value:function(a){if(0==d){if(e=a,d=-1,b)try{e=b(e),d=1}catch(c){e=c}g(f)}}},promise:{enumerable:!0,configurable:!1,value:Object.defineProperties(new Object,{$$id:{enumerable:!1,configurable:!1,value:h.$$id},then:{enumerable:!0,configurable:!1,value:function(a,b){var e=new c(a,b);return 0==d?f.push(e):g([e]),e.promise}},"catch":{enumerable:!0,configurable:!1,value:function(a){return this.then(null,a)}}})}})}function d(a){if(!(this instanceof d))return new d(a);if("function"!=typeof a)throw new TypeError("Executor is not a function");var b=new c;Object.defineProperties(this,{$$id:{enumerable:!1,configurable:!1,value:b.$$id},then:{enumerable:!0,configurable:!1,value:function(){return b.promise.then.apply(b.promise,arguments)}},"catch":{enumerable:!0,configurable:!1,value:function(){return b.promise.catch.apply(b.promise,arguments)}}});try{a(b.resolve,b.reject)}catch(e){b.reject(e)}}function e(a,b){a="Esquire: "+(a||"Unknown error");var c="";if(b&&b.length)for(var d=0;d<b.length;d++)b[d]&&(c+=" -> "+b[d]);c&&(a+=" resolving"+c),Error.call(this,a),this.message=a;var e=this.stack||(new Error).stack;e&&(e=e.replace(new RegExp("^(Error|"+this.name+")\n"),""),this.stack=this.name+": "+this.message+"\n"+e)}function f(a,b){e.call(this,"Module '"+a+"' not found",b)}function g(a,b,c){e.call(this,"Module '"+a+"' failed to initialize",c),b&&(this.message=this.message+" [Cause: "+(b.message?b.message:"[no message]")+"]",this.cause=b)}function h(a,b){e.call(this,"Module '"+a+"' has circular dependencies",b)}function i(a,b,c,d){a=o(a);for(var e in b)b[e]=o(b[e]);Object.defineProperty(this,"name",{enumerable:!0,configurable:!1,value:a}),Object.defineProperty(this,"dependencies",{enumerable:!0,configurable:!1,value:b}),Object.defineProperty(this,"constructor",{enumerable:!0,configurable:!1,value:c}),Object.defineProperty(this,"$$dynamic",{enumerable:!1,configurable:!1,value:d||!1}),Object.defineProperty(this,"$$script",{enumerable:!1,configurable:!1,get:function(){return"Esquire.define("+JSON.stringify(this.name)+","+JSON.stringify(this.dependencies)+","+c.toString()+");"}}),Object.freeze(this)}function j(a){i.call(this,a,["$global"],function(a){function b(a,c,d){if(!d&&a in c)return c[a];var e=["Ms","ms","Moz","moz","WebKit","webkit"];for(var f in e){var g=e[f]+a;if(g in c)return c[g]}return a[0]!==a[0].toUpperCase()?b(a[0].toUpperCase()+a.substring(1),c,!0):void 0}function c(a,d){if(!d)return void 0;if(!a)return void 0;switch(a.length){case 0:return void 0;case 1:return b(a[0],d);default:return c(a.slice(1),b(a[0],d))}}return c(this.name.substring(8).split("."),a)},!0)}function k(a){i.call(this,a,[],function(){throw new e("The constructor for '"+a+"' should not be called'")},!0)}function l(a){if(!a)return[];for(var b=[],c=0;c<a.length;c++){var d=a[c];if("string"==typeof d)b.push(d);else if("function"==typeof d)b.push(d);else if(Array.isArray(d))b=b.concat(l(d));else{if("object"!=typeof d||"number"!=typeof d.length)throw new e("Invalid dependency: "+JSON.stringify(d));b=b.concat(l(d))}}return b}function m(){var a=l(arguments),b={arguments:[],"function":null};if(!a.length)return b;"function"==typeof a[a.length-1]&&(b.function=a.splice(-1)[0]);for(var c in a){var d=a[c];if("string"!=typeof d)throw new e("Found "+typeof d+" but needed string: "+d);b.arguments.push(d)}return b}function n(a){return/^\$global[\/\.].+/.test(a)}function o(a){return n(a)?"$global/"+a.substring(8):a}function p(){if(1==arguments.length&&arguments[0].name&&arguments[0].constructor){var a=arguments[0];return p(a.name,a.dependencies||[],a.constructor)}var b,c,d=m(arguments),f=[];if(!d.arguments.length)throw new e("No module name specified");if(b=o(d.arguments.splice(0,1)[0]),f=d.arguments,t[b])throw new e("Module '"+b+"' already defined");if(!d.function)throw new e("No constructor function specified for module '"+b+"'");return c=d.function,t[b]=new i(b,f,c),t[b]}function q(a,b,c){if(c||(c=[]),!a)throw new e("No module or module name specified");if("string"==typeof a){if(!t[a])throw new f(m,c);a=t[a]}if(c.indexOf(a.name)>=0)throw new h(a.name,c);var d=[];c.push(a.name);for(var g in a.dependencies){var i=a.dependencies[g],k=t[i];if(k){if(d.push(k),b){var l=q(k,c);for(var m in l)d.push(l[m])}}else{if(!n(i))throw new f(a.dependencies[g],c);d.push(new j(i))}}return c.pop(),d}function r(a){function f(d,h){if(l[d.name])return l[d.name];var i=q(d,!1,h),j=[];for(var m in i){var n=i[m];l[n.name]?j.push(l[n.name]):(h.push(d.name),j.push(f(n,h)),h.pop())}var o=h.slice(0),p=new c;d.name&&!d.$$dynamic&&(l[d.name]=p.promise);var r=a-5*o.length;50>r&&(r=50);var s=b.setTimeout(function(){var a=new e("Timeout reached waiting for module '"+d.name+"'",o);p.reject(a)},r),t=function(a){b.clearTimeout(s),d.name&&!d.$$dynamic&&(l[d.name]=a),p.resolve(a)},u=function(a){b.clearTimeout(s),p.reject(a)};return k.all(j).then(function(a){try{var b=d.constructor.apply(d,a);b&&"function"==typeof b.then?b.then(t,function(a){var b=new g(d.name,a,o);u(b)}):t(b)}catch(c){u(new g(d.name,c,o))}},function(a){u(a)}),p.promise}function h(){return 1==arguments.length&&"string"==typeof arguments[0]?j([arguments[0]],function(a){return a}):j(arguments,function(){for(var a=[],b=0;b<arguments.length;b++)a.push(arguments[b]);return a})}function j(){var a=m(arguments);if(!a.function)throw new e("Callback for injection unspecified");var b=new i(null,a.arguments,a.function);try{return f(b,[])}catch(c){return k.reject(c)}}if(!(this instanceof r))return new r(k);var k=b.Promise||d;if(void 0===a)a=2e3;else{if(a=Number(a),0/0===a)throw new e("Timeout is not a number");if(100>a)throw new e("Timeout must be greater or equal than 100ms")}var l={$global:b,$esquire:this,$promise:k,$deferred:c};Object.defineProperties(this,{inject:{enumerable:!0,configurable:!1,value:j},require:{enumerable:!0,configurable:!1,value:h}})}b.console||(b.console={}),b.console.error||(b.console.error=function(){}),b.console.warn||(b.console.warn=function(){}),b.console.log||(b.console.log=function(){}),b.console.info||(b.console.info=function(){}),b.console.debug||(b.console.debug=function(){});var s=0;c.prototype=Object.create(Object.prototype),c.prototype.constructor=c,c.prototype.name="Deferred",d.prototype=Object.create(Object.prototype),d.prototype.constructor=d,d.prototype.name="Promise",Object.defineProperty(d,"all",{enumerable:!0,configurable:!1,value:function(a){if(!Array.isArray(a))return d.reject(new TypeError("Invalid argument"));var b=new c;if(0==a.length)return b.resolve([]),b.promise;for(var e=new Array(a.length),f=a.length,g=0;g<a.length;g++)!function(c){var d=a[c];d&&"function"==typeof d.then?d.then(function(a){e[c]=a,0==--f&&b.resolve(e)},function(a){b.reject(a)}):(e[c]=d,0==--f&&b.resolve(e))}(g);return b.promise}}),Object.defineProperty(d,"race",{enumerable:!0,configurable:!1,value:function(a){if(!Array.isArray(a))return d.reject(new TypeError("Invalid argument"));var b=new c;for(var e in a){var f=a[e];f&&"function"==typeof f.then?f.then(function(a){b.resolve(a)},function(a){b.reject(a)}):b.resolve(f)}return b.promise}}),Object.defineProperty(d,"resolve",{enumerable:!0,configurable:!1,value:function(a){var b=new c;return a&&"function"==typeof a.then?a.then(function(a){b.resolve(a)},function(a){b.reject(a)}):b.resolve(a),b.promise}}),Object.defineProperty(d,"reject",{enumerable:!0,configurable:!1,value:function(a){var b=new c;return b.reject(a),b.promise}}),e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.prototype.name="EsquireError",f.prototype=Object.create(e.prototype),f.prototype.constructor=f,f.prototype.name="NoModuleError",g.prototype=Object.create(e.prototype),g.prototype.constructor=g,g.prototype.name="ModuleConstructorError",h.prototype=Object.create(e.prototype),h.prototype.constructor=h,h.prototype.name="CircularDependencyError",j.prototype=Object.create(i.prototype),j.prototype.constructor=j,j.prototype.name="GlobalModule",k.prototype=Object.create(i.prototype),k.prototype.constructor=k,k.prototype.name="InternalModule";var t={$global:new k("$global"),$esquire:new k("$esquire"),$promise:new k("$promise"),$deferred:new k("$deferred")};if(Object.defineProperties(r,{$$script:{enumerable:!1,configurable:!1,value:a.toString()},$$normalize:{enumerable:!1,configurable:!1,value:m},$$Promise:{enumerable:!1,configurable:!1,value:d},$$Deferred:{enumerable:!1,configurable:!1,value:c},define:{enumerable:!0,configurable:!1,value:p},resolve:{enumerable:!0,configurable:!1,value:q},modules:{enumerable:!0,configurable:!1,get:function(){var a={};for(var b in t)a[b]=t[b];return Object.freeze(a)}},module:{enumerable:!0,configurable:!1,value:function(a){return a=o(a),a in t?t[a]:n(a)?new j(a):null}}}),b.Esquire)throw new Error("Esquire already defined in global scope");b.Esquire=r;var u=new r;b.esquire=function(){if(0==arguments.length)throw new e("No dependencies/callback specified");var a=m(arguments);return a.function?u.inject(a.arguments,a.function):u.require(1==arguments.length&&"string"==typeof arguments[0]?arguments[0]:a.arguments)}}(function(){try{return window}catch(a){return global}}()),function(a){function b(a){var b=a.filename||a.target&&a.target.src;if(g[b]){if(a.stopPropagation&&a.stopPropagation(),a.preventDefault&&a.preventDefault(),a.target&&a.target.parentNode)try{a.target.parentNode.removeChild(a.target)}catch(c){}var d=g[b];return delete g[b],d.remaining-=1,{script:b,promise:d}}}function c(a){var c=b(a);c&&(console.debug("Esquire: Successfully loaded script '",c.script,"'"),0==c.promise.remaining&&c.promise.resolve(Esquire.modules))}function d(a){var c=b(a);if(c){console.warn("Esquire: Unable to load script '",c.script,"'");var d=a.error||new Error("Unable to load script '"+c.script+"'");c.promise.reject(d)}}function e(){if(!h)throw new Error("Esquire: Document not available");var a=h.getElementsByTagName("script")[0],b=a.parentNode,e=new Esquire.$$Deferred(function(a){return a},function(a){throw a});e.remaining=0;var i=Esquire.$$normalize(arguments).arguments,j=[];for(var k in i)!function(a){var b=h.createElement("script");b.async=!0,b.defer=!0,b.src=a,a=b.src,f[a]?console.debug("Esquire: Script '"+a+"' already loaded"):g[a]?console.debug("Esquire: Script '"+a+"' already being loaded"):(b.addEventListener("load",c,!1),b.addEventListener("error",d,!1),g[a]=e,e.remaining+=1,j.push(b))}(i[k]);if(0==j.length)e.resolve(Esquire.modules);else for(var k in j)console.debug("Esquire: About to load '"+j[k].src+"'"),b.insertBefore(j[k],a);return e.promise}if(!a.Esquire)throw new Error("Esquire not available");var f={},g={};a.addEventListener("error",d,!0);var h=a.document;a.Esquire||(a.Esquire={}),a.Esquire.load=e}(window);

@@ -1,1 +0,1 @@

"use strict";!function a(b){function c(a,b){if(!(this instanceof c))return new c(a,b);var d=0,e=null,f=[],g=function(a){var b=d>0?"resolve":0>d?"reject":null;if(b)for(var c in a)a[c][b](e)},h=this;Object.defineProperties(this,{resolve:{enumerable:!0,configurable:!1,value:function(b){if(b&&"function"==typeof b.then)b.then(function(a){h.resolve(a)},function(a){h.reject(a)});else if(0==d){if(e=b,d=1,a)try{e=a(e)}catch(c){e=c,d=-1}g(f)}}},reject:{enumerable:!0,configurable:!1,value:function(a){if(0==d){if(e=a,d=-1,b)try{e=b(e),d=1}catch(c){e=c}g(f)}}},promise:{enumerable:!0,configurable:!1,value:Object.defineProperties(new Object,{then:{enumerable:!0,configurable:!1,value:function(a,b){var e=new c(a,b);return 0==d?f.push(e):g([e]),e.promise}},"catch":{enumerable:!0,configurable:!1,value:function(a){return this.then(null,a)}}})}})}function d(a){if(!(this instanceof d))return new d(a);if("function"!=typeof a)throw new TypeError("Executor is not a function");var b=new c;Object.defineProperty(this,"then",{enumerable:!0,configurable:!1,value:b.promise.then}),Object.defineProperty(this,"catch",{enumerable:!0,configurable:!1,value:b.promise["catch"]});try{a(b.resolve,b.reject)}catch(e){b.reject(e)}}function e(a,b){a="Esquire: "+(a||"Unknown error");var c="";if(b&&b.length)for(var d=0;d<b.length;d++)b[d]&&(c+=" -> "+b[d]);if(c&&(a+=" resolving"+c),Error.call(this,a),this.message=a,this.stack){var e=this.stack;e=e.replace(new RegExp("^"+this.name+"\n"),""),this.stack=this.name+": "+this.message+"\n"+e}}function f(a,b){e.call(this,"Module '"+a+"' not found",b)}function g(a,b,c){e.call(this,"Module '"+a+"' failed to initialize",c),b&&(this.message=this.message+" [Cause: "+(b.message?b.message:"[no message]")+"]",this.cause=b)}function h(a,b){e.call(this,"Module '"+a+"' has circular dependencies",b)}function i(a,b,c,d){a=o(a);for(var e in b)b[e]=o(b[e]);Object.defineProperty(this,"name",{enumerable:!0,configurable:!1,value:a}),Object.defineProperty(this,"dependencies",{enumerable:!0,configurable:!1,value:b}),Object.defineProperty(this,"constructor",{enumerable:!0,configurable:!1,value:c}),Object.defineProperty(this,"$$dynamic",{enumerable:!1,configurable:!1,value:d||!1}),Object.defineProperty(this,"$$script",{enumerable:!1,configurable:!1,get:function(){return"Esquire.define("+JSON.stringify(this.name)+","+JSON.stringify(this.dependencies)+","+c.toString()+");"}}),Object.freeze(this)}function j(a){i.call(this,a,["$global"],function(a){function b(a,c,d){if(!d&&a in c)return c[a];var e=["Ms","ms","Moz","moz","WebKit","webkit"];for(var f in e){var g=e[f]+a;if(g in c)return c[g]}return a[0]!==a[0].toUpperCase()?b(a[0].toUpperCase()+a.substring(1),c,!0):void 0}function c(a,d){if(!d)return void 0;if(!a)return void 0;switch(a.length){case 0:return void 0;case 1:return b(a[0],d);default:return c(a.slice(1),b(a[0],d))}}return c(this.name.substring(8).split("."),a)},!0)}function k(a){i.call(this,a,[],function(){throw new e("The constructor for '"+a+"' should not be called'")},!0)}function l(a){if(!a)return[];for(var b=[],c=0;c<a.length;c++){var d=a[c];if("string"==typeof d)b.push(d);else if("function"==typeof d)b.push(d);else if(Array.isArray(d))b=b.concat(l(d));else{if("object"!=typeof d||"number"!=typeof d.length)throw new e("Invalid dependency: "+JSON.stringify(d));b=b.concat(l(d))}}return b}function m(){var a=l(arguments),b={arguments:[],"function":null};if(!a.length)return b;"function"==typeof a[a.length-1]&&(b.function=a.splice(-1)[0]);for(var c in a){var d=a[c];if("string"!=typeof d)throw new e("Found "+typeof d+" but needed string: "+d);b.arguments.push(d)}return b}function n(a){return/^\$global[\/\.].+/.test(a)}function o(a){return n(a)?"$global/"+a.substring(8):a}function p(){if(1==arguments.length&&arguments[0].name&&arguments[0].constructor){var a=arguments[0];return p(a.name,a.dependencies||[],a.constructor)}var b,c,d=m(arguments),f=[];if(!d.arguments.length)throw new e("No module name specified");if(b=o(d.arguments.splice(0,1)[0]),f=d.arguments,s[b])throw new e("Module '"+b+"' already defined");if(!d.function)throw new e("No constructor function specified for module '"+b+"'");return c=d.function,s[b]=new i(b,f,c),s[b]}function q(a,b,c){if(c||(c=[]),!a)throw new e("No module or module name specified");if("string"==typeof a){if(!s[a])throw new f(m,c);a=s[a]}if(c.indexOf(a.name)>=0)throw new h(a.name,c);var d=[];c.push(a.name);for(var g in a.dependencies){var i=a.dependencies[g],k=s[i];if(k){if(d.push(k),b){var l=q(k,c);for(var m in l)d.push(l[m])}}else{if(!n(i))throw new f(a.dependencies[g],c);d.push(new j(i))}}return c.pop(),d}function r(a){function f(c,d){if(l[c.name])return l[c.name];var h=q(c,!1,d),i=[];for(var j in h){var m=h[j];l[m.name]?i.push(l[m.name]):(d.push(c.name),i.push(f(m,d)),d.pop())}var n=d.slice(0),o=new k(function(f,h){var j=a-10*d.length,l=b.setTimeout(function(){h(new e("Timeout reached waiting for module '"+c.name+"'",n))},50>j?50:j),m=function(a){b.clearTimeout(l),f(a)},o=function(a){b.clearTimeout(l),h(a)};k.all(i).then(function(a){try{var b=c.constructor.apply(c,a);k.resolve(b).then(function(a){m(a)},function(a){o(new g(c.name,a,n)),o(a)})}catch(d){o(new g(c.name,d,n))}},function(a){o(a)})});return c.name&&!c.$$dynamic&&(l[c.name]=o),o}function h(){return 1==arguments.length&&"string"==typeof arguments[0]?j([arguments[0]],function(a){return a}):j(arguments,function(){for(var a=[],b=0;b<arguments.length;b++)a.push(arguments[b]);return a})}function j(){var a=m(arguments);if(!a.function)throw new e("Callback for injection unspecified");var b=new i(null,a.arguments,a.function);try{return f(b,[])}catch(c){return k.reject(c)}}if(!(this instanceof r))return new r(k);var k=b.Promise||d;if(void 0===a)a=2e3;else{if(a=Number(a),0/0===a)throw new e("Timeout is not a number");if(100>a)throw new e("Timeout must be greater or equal than 100ms")}var l={$global:b,$esquire:this,$promise:k,$deferred:c};Object.defineProperties(this,{inject:{enumerable:!0,configurable:!1,value:j},require:{enumerable:!0,configurable:!1,value:h}})}c.prototype=Object.create(Object.prototype),c.prototype.constructor=c,c.prototype.name="Deferred",d.prototype=Object.create(Object.prototype),d.prototype.constructor=d,d.prototype.name="Promise",Object.defineProperty(d,"all",{enumerable:!0,configurable:!1,value:function(a){if(!Array.isArray(a))return d.reject(new TypeError("Invalid argument"));var b=[];for(var e in a)b.push(d.resolve(a[e]));if(0==b.length)return d.resolve([]);for(var f=new c,g=new Array(b.length),h=b.length,e=0;e<b.length;e++)!function(a){b[a].then(function(b){g[a]=b,0==--h&&f.resolve(g)},function(a){f.reject(a)})}(e);return f.promise}}),Object.defineProperty(d,"race",{enumerable:!0,configurable:!1,value:function(a){if(!Array.isArray(a))return d.reject(new TypeError("Invalid argument"));var b=new c;for(var e in a)d.resolve(a[e]).then(function(a){b.resolve(a)},function(a){b.reject(a)});return b.promise}}),Object.defineProperty(d,"resolve",{enumerable:!0,configurable:!1,value:function(a){return new d(function(b,c){a&&a.then&&"function"==typeof a.then?a.then(b,c):b(a)},!0)}}),Object.defineProperty(d,"reject",{enumerable:!0,configurable:!1,value:function(a){return new d(function(b,c){c(a)},!0)}}),e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.prototype.name="EsquireError",f.prototype=Object.create(e.prototype),f.prototype.constructor=f,f.prototype.name="NoModuleError",g.prototype=Object.create(e.prototype),g.prototype.constructor=g,g.prototype.name="ModuleConstructorError",h.prototype=Object.create(e.prototype),h.prototype.constructor=h,h.prototype.name="CircularDependencyError",j.prototype=Object.create(i.prototype),j.prototype.constructor=j,j.prototype.name="GlobalModule",k.prototype=Object.create(i.prototype),k.prototype.constructor=k,k.prototype.name="InternalModule";var s={$global:new k("$global"),$esquire:new k("$esquire"),$promise:new k("$promise"),$deferred:new k("$deferred")};if(Object.defineProperties(r,{$$script:{enumerable:!1,configurable:!1,value:a.toString()},$$normalize:{enumerable:!1,configurable:!1,value:m},$$Promise:{enumerable:!1,configurable:!1,value:d},$$Deferred:{enumerable:!1,configurable:!1,value:c},define:{enumerable:!0,configurable:!1,value:p},resolve:{enumerable:!0,configurable:!1,value:q},modules:{enumerable:!0,configurable:!1,get:function(){var a={};for(var b in s)a[b]=s[b];return Object.freeze(a)}},module:{enumerable:!0,configurable:!1,value:function(a){return a=o(a),a in s?s[a]:n(a)?new j(a):null}}}),b.Esquire)throw new Error("Esquire already defined in global scope");b.Esquire=r;var t=new r;b.esquire=function(){if(0==arguments.length)throw new e("No dependencies/callback specified");var a=m(arguments);return a.function?t.inject(a.arguments,a.function):t.require(1==arguments.length&&"string"==typeof arguments[0]?arguments[0]:a.arguments)}}(function(){try{return window}catch(a){return global}}());
"use strict";!function a(b){function c(a,b){if(!(this instanceof c))return new c(a,b);var d=0,e=null,f=[],g=function(a){var b=d>0?"resolve":0>d?"reject":null;if(b)for(var c in a)a[c][b](e)},h=this;Object.defineProperties(this,{$$id:{enumerable:!1,configurable:!1,value:++s},resolve:{enumerable:!0,configurable:!1,value:function(b){if(b&&"function"==typeof b.then)b.then(function(a){h.resolve(a)},function(a){h.reject(a)});else if(0==d){if(e=b,d=1,a)try{e=a(e)}catch(c){e=c,d=-1}g(f)}}},reject:{enumerable:!0,configurable:!1,value:function(a){if(0==d){if(e=a,d=-1,b)try{e=b(e),d=1}catch(c){e=c}g(f)}}},promise:{enumerable:!0,configurable:!1,value:Object.defineProperties(new Object,{$$id:{enumerable:!1,configurable:!1,value:h.$$id},then:{enumerable:!0,configurable:!1,value:function(a,b){var e=new c(a,b);return 0==d?f.push(e):g([e]),e.promise}},"catch":{enumerable:!0,configurable:!1,value:function(a){return this.then(null,a)}}})}})}function d(a){if(!(this instanceof d))return new d(a);if("function"!=typeof a)throw new TypeError("Executor is not a function");var b=new c;Object.defineProperties(this,{$$id:{enumerable:!1,configurable:!1,value:b.$$id},then:{enumerable:!0,configurable:!1,value:function(){return b.promise.then.apply(b.promise,arguments)}},"catch":{enumerable:!0,configurable:!1,value:function(){return b.promise.catch.apply(b.promise,arguments)}}});try{a(b.resolve,b.reject)}catch(e){b.reject(e)}}function e(a,b){a="Esquire: "+(a||"Unknown error");var c="";if(b&&b.length)for(var d=0;d<b.length;d++)b[d]&&(c+=" -> "+b[d]);c&&(a+=" resolving"+c),Error.call(this,a),this.message=a;var e=this.stack||(new Error).stack;e&&(e=e.replace(new RegExp("^(Error|"+this.name+")\n"),""),this.stack=this.name+": "+this.message+"\n"+e)}function f(a,b){e.call(this,"Module '"+a+"' not found",b)}function g(a,b,c){e.call(this,"Module '"+a+"' failed to initialize",c),b&&(this.message=this.message+" [Cause: "+(b.message?b.message:"[no message]")+"]",this.cause=b)}function h(a,b){e.call(this,"Module '"+a+"' has circular dependencies",b)}function i(a,b,c,d){a=o(a);for(var e in b)b[e]=o(b[e]);Object.defineProperty(this,"name",{enumerable:!0,configurable:!1,value:a}),Object.defineProperty(this,"dependencies",{enumerable:!0,configurable:!1,value:b}),Object.defineProperty(this,"constructor",{enumerable:!0,configurable:!1,value:c}),Object.defineProperty(this,"$$dynamic",{enumerable:!1,configurable:!1,value:d||!1}),Object.defineProperty(this,"$$script",{enumerable:!1,configurable:!1,get:function(){return"Esquire.define("+JSON.stringify(this.name)+","+JSON.stringify(this.dependencies)+","+c.toString()+");"}}),Object.freeze(this)}function j(a){i.call(this,a,["$global"],function(a){function b(a,c,d){if(!d&&a in c)return c[a];var e=["Ms","ms","Moz","moz","WebKit","webkit"];for(var f in e){var g=e[f]+a;if(g in c)return c[g]}return a[0]!==a[0].toUpperCase()?b(a[0].toUpperCase()+a.substring(1),c,!0):void 0}function c(a,d){if(!d)return void 0;if(!a)return void 0;switch(a.length){case 0:return void 0;case 1:return b(a[0],d);default:return c(a.slice(1),b(a[0],d))}}return c(this.name.substring(8).split("."),a)},!0)}function k(a){i.call(this,a,[],function(){throw new e("The constructor for '"+a+"' should not be called'")},!0)}function l(a){if(!a)return[];for(var b=[],c=0;c<a.length;c++){var d=a[c];if("string"==typeof d)b.push(d);else if("function"==typeof d)b.push(d);else if(Array.isArray(d))b=b.concat(l(d));else{if("object"!=typeof d||"number"!=typeof d.length)throw new e("Invalid dependency: "+JSON.stringify(d));b=b.concat(l(d))}}return b}function m(){var a=l(arguments),b={arguments:[],"function":null};if(!a.length)return b;"function"==typeof a[a.length-1]&&(b.function=a.splice(-1)[0]);for(var c in a){var d=a[c];if("string"!=typeof d)throw new e("Found "+typeof d+" but needed string: "+d);b.arguments.push(d)}return b}function n(a){return/^\$global[\/\.].+/.test(a)}function o(a){return n(a)?"$global/"+a.substring(8):a}function p(){if(1==arguments.length&&arguments[0].name&&arguments[0].constructor){var a=arguments[0];return p(a.name,a.dependencies||[],a.constructor)}var b,c,d=m(arguments),f=[];if(!d.arguments.length)throw new e("No module name specified");if(b=o(d.arguments.splice(0,1)[0]),f=d.arguments,t[b])throw new e("Module '"+b+"' already defined");if(!d.function)throw new e("No constructor function specified for module '"+b+"'");return c=d.function,t[b]=new i(b,f,c),t[b]}function q(a,b,c){if(c||(c=[]),!a)throw new e("No module or module name specified");if("string"==typeof a){if(!t[a])throw new f(m,c);a=t[a]}if(c.indexOf(a.name)>=0)throw new h(a.name,c);var d=[];c.push(a.name);for(var g in a.dependencies){var i=a.dependencies[g],k=t[i];if(k){if(d.push(k),b){var l=q(k,c);for(var m in l)d.push(l[m])}}else{if(!n(i))throw new f(a.dependencies[g],c);d.push(new j(i))}}return c.pop(),d}function r(a){function f(d,h){if(l[d.name])return l[d.name];var i=q(d,!1,h),j=[];for(var m in i){var n=i[m];l[n.name]?j.push(l[n.name]):(h.push(d.name),j.push(f(n,h)),h.pop())}var o=h.slice(0),p=new c;d.name&&!d.$$dynamic&&(l[d.name]=p.promise);var r=a-5*o.length;50>r&&(r=50);var s=b.setTimeout(function(){var a=new e("Timeout reached waiting for module '"+d.name+"'",o);p.reject(a)},r),t=function(a){b.clearTimeout(s),d.name&&!d.$$dynamic&&(l[d.name]=a),p.resolve(a)},u=function(a){b.clearTimeout(s),p.reject(a)};return k.all(j).then(function(a){try{var b=d.constructor.apply(d,a);b&&"function"==typeof b.then?b.then(t,function(a){var b=new g(d.name,a,o);u(b)}):t(b)}catch(c){u(new g(d.name,c,o))}},function(a){u(a)}),p.promise}function h(){return 1==arguments.length&&"string"==typeof arguments[0]?j([arguments[0]],function(a){return a}):j(arguments,function(){for(var a=[],b=0;b<arguments.length;b++)a.push(arguments[b]);return a})}function j(){var a=m(arguments);if(!a.function)throw new e("Callback for injection unspecified");var b=new i(null,a.arguments,a.function);try{return f(b,[])}catch(c){return k.reject(c)}}if(!(this instanceof r))return new r(k);var k=b.Promise||d;if(void 0===a)a=2e3;else{if(a=Number(a),0/0===a)throw new e("Timeout is not a number");if(100>a)throw new e("Timeout must be greater or equal than 100ms")}var l={$global:b,$esquire:this,$promise:k,$deferred:c};Object.defineProperties(this,{inject:{enumerable:!0,configurable:!1,value:j},require:{enumerable:!0,configurable:!1,value:h}})}b.console||(b.console={}),b.console.error||(b.console.error=function(){}),b.console.warn||(b.console.warn=function(){}),b.console.log||(b.console.log=function(){}),b.console.info||(b.console.info=function(){}),b.console.debug||(b.console.debug=function(){});var s=0;c.prototype=Object.create(Object.prototype),c.prototype.constructor=c,c.prototype.name="Deferred",d.prototype=Object.create(Object.prototype),d.prototype.constructor=d,d.prototype.name="Promise",Object.defineProperty(d,"all",{enumerable:!0,configurable:!1,value:function(a){if(!Array.isArray(a))return d.reject(new TypeError("Invalid argument"));var b=new c;if(0==a.length)return b.resolve([]),b.promise;for(var e=new Array(a.length),f=a.length,g=0;g<a.length;g++)!function(c){var d=a[c];d&&"function"==typeof d.then?d.then(function(a){e[c]=a,0==--f&&b.resolve(e)},function(a){b.reject(a)}):(e[c]=d,0==--f&&b.resolve(e))}(g);return b.promise}}),Object.defineProperty(d,"race",{enumerable:!0,configurable:!1,value:function(a){if(!Array.isArray(a))return d.reject(new TypeError("Invalid argument"));var b=new c;for(var e in a){var f=a[e];f&&"function"==typeof f.then?f.then(function(a){b.resolve(a)},function(a){b.reject(a)}):b.resolve(f)}return b.promise}}),Object.defineProperty(d,"resolve",{enumerable:!0,configurable:!1,value:function(a){var b=new c;return a&&"function"==typeof a.then?a.then(function(a){b.resolve(a)},function(a){b.reject(a)}):b.resolve(a),b.promise}}),Object.defineProperty(d,"reject",{enumerable:!0,configurable:!1,value:function(a){var b=new c;return b.reject(a),b.promise}}),e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.prototype.name="EsquireError",f.prototype=Object.create(e.prototype),f.prototype.constructor=f,f.prototype.name="NoModuleError",g.prototype=Object.create(e.prototype),g.prototype.constructor=g,g.prototype.name="ModuleConstructorError",h.prototype=Object.create(e.prototype),h.prototype.constructor=h,h.prototype.name="CircularDependencyError",j.prototype=Object.create(i.prototype),j.prototype.constructor=j,j.prototype.name="GlobalModule",k.prototype=Object.create(i.prototype),k.prototype.constructor=k,k.prototype.name="InternalModule";var t={$global:new k("$global"),$esquire:new k("$esquire"),$promise:new k("$promise"),$deferred:new k("$deferred")};if(Object.defineProperties(r,{$$script:{enumerable:!1,configurable:!1,value:a.toString()},$$normalize:{enumerable:!1,configurable:!1,value:m},$$Promise:{enumerable:!1,configurable:!1,value:d},$$Deferred:{enumerable:!1,configurable:!1,value:c},define:{enumerable:!0,configurable:!1,value:p},resolve:{enumerable:!0,configurable:!1,value:q},modules:{enumerable:!0,configurable:!1,get:function(){var a={};for(var b in t)a[b]=t[b];return Object.freeze(a)}},module:{enumerable:!0,configurable:!1,value:function(a){return a=o(a),a in t?t[a]:n(a)?new j(a):null}}}),b.Esquire)throw new Error("Esquire already defined in global scope");b.Esquire=r;var u=new r;b.esquire=function(){if(0==arguments.length)throw new e("No dependencies/callback specified");var a=m(arguments);return a.function?u.inject(a.arguments,a.function):u.require(1==arguments.length&&"string"==typeof arguments[0]?arguments[0]:a.arguments)}}(function(){try{return window}catch(a){return global}}());

@@ -85,4 +85,11 @@ 'use strict';

}, function(failure) {
console.error("Esquire: Unable to run Karma", failure, failure.stack);
karma.error(failure);
var message = "Esquire: Unable to run Karma: " + failure.name + " - " + failure.message;
if (failure.stack) message += "\n" + failure.stack;
var error = failure.cause;
while (error) {
message += "\n- Caused by: " + error.name + " - " + error.message;
if (error.stack) message += "\n" + error.stack;
error = error.cause;
}
karma.error(message);
});

@@ -89,0 +96,0 @@

@@ -54,2 +54,3 @@ module.exports = function(grunt) {

"cleverLinks": true,
"windowTitle": "Esquire v." + require('./package.json').version
},

@@ -56,0 +57,0 @@ "markdown": {

'use strict';
var glob = require('glob');
var path = require('path');

@@ -11,2 +12,6 @@ var fs = require('fs');

/* Listen to definitions */
var definitions = [];
Esquire.on('define', definitions.push.bind(definitions));
/* We are sure we have Esquire in globals */

@@ -24,3 +29,3 @@ function EsquireAdapter() {

/* Properties of static members */
Object.defineProperties(EsquireAdapter, {

@@ -33,3 +38,54 @@ 'define': { enumerable: true, configurable: false, value: function() { return global.Esquire.define .apply(global.Esquire, arguments) } },

/* Our loader */
EsquireAdapter.load = function(pattern, caller) {
/* Clear our definitions */
definitions.splice(0);
/* Prepare options for pattern loading */
var options = { sync: true, nodir: true };
if (caller && caller.filename) {
options.cwd = path.dirname(caller.filename);
} else {
options.cwd = process.cwd();
}
/* Find all the files and load them */
glob(pattern, options).forEach(function(file) {
require(path.join(options.cwd, file));
});
/* Zero out the definitions */
var loaded = definitions.splice(0);
/* If we have a caller, process loaded modules */
if (caller && (typeof(caller.require) === 'function')) {
var modules = Esquire.modules;
var unsatisfied = [];
/* Check unsatisfied "id" dependencies */
loaded.forEach(function(module) {
module.dependencies.forEach(function(dependency) {
if (dependency in modules) return;
if (!(/^[^\$\/\.]+$/.test(dependency))) return;
if (unsatisfied.indexOf(dependency) >= 0) return;
unsatisfied.push(dependency);
});
});
/* Try to load, ignore any error */
unsatisfied.forEach(function(dependency) {
try {
caller.require(dependency);
console.log("Loaded module '" + dependency + "'");
} catch (error) {
// swallow any error...
}
});
}
/* Return our modules */
return Esquire.modules;
};
/* Export our adapter */
module.exports = EsquireAdapter;
{
"name": "esquire",
"version": "1.0.1",
"version": "1.0.2",
"main": "node-adapter.js",
"description": "USRZ Esquire API",
"description": "Esquire: asynchronous injection framework",
"repository": {

@@ -7,0 +7,0 @@ "type": "git",

@@ -8,2 +8,10 @@ 'use strict';

/* We might need a working console */
if (!global.console) global.console = {};
if (!global.console.error) global.console.error = function(){};
if (!global.console.warn) global.console.warn = function(){};
if (!global.console.log) global.console.log = function(){};
if (!global.console.info) global.console.info = function(){};
if (!global.console.debug) global.console.debug = function(){};
/*==========================================================================*

@@ -26,2 +34,3 @@ | *======================================================================* |

*/
var deferredId = 0;
function Deferred(onSuccess, onFailure) {

@@ -49,2 +58,3 @@

Object.defineProperties(this, {
"$$id": { enumerable: false, configurable: false, value: (++deferredId) },

@@ -64,2 +74,3 @@ /**

if (success && (typeof(success.then) === 'function')) {
/* If we were given a "then-able" just call ourselves back */

@@ -73,2 +84,3 @@ success.then(function(success) {

} else {
/* We were given a success, resolve immediately */

@@ -117,2 +129,3 @@ if (status == 0) {

Object.defineProperties(new Object(), {
"$$id": { enumerable: false, configurable: false, value: deferred.$$id },
"then": { enumerable: true, configurable: false, value: function(onSuccess, onFailure) {

@@ -180,37 +193,37 @@ var chained = new Deferred(onSuccess, onFailure);

/**
* Appends fulfillment and rejection handlers to this {@link Promise}, and
* returns a **new** promise resolving to the return value of the called
* handler.
*
* @param {function} [onSuccess] - The handler to call when this
* {@link Promise} has been successfully resolved.
* @param {function} [onFailure] - The handler to call when this
* {@link Promise} has been rejected.
* @returns {Promise} A new {@link Promise} resolving to the return value
* of the called handler
* @function module:$promise.Promise#then
*/
Object.defineProperty(this, 'then', {
enumerable: true,
configurable: false,
value: deferred.promise['then']
});
Object.defineProperties(this, {
'$$id': { enumerable: false, configurable: false, value: deferred.$$id },
/**
* Appends a rejection handler to this {@link Promise}, and returns a
* **new** promise resolving to the return value of the called handler.
*
* This is equivalent to calling `then(null, onFailure)`.
*
* @param {function} [onFailure] - The handler to call when this
* {@link Promise} has been rejected.
* @returns {Promise} A new {@link Promise} resolving to the return value
* of the called handler
* @function module:$promise.Promise#catch
*/
Object.defineProperty(this, 'catch', {
enumerable: true,
configurable: false,
value: deferred.promise['catch']
/**
* Appends fulfillment and rejection handlers to this {@link Promise}, and
* returns a **new** promise resolving to the return value of the called
* handler.
*
* @param {function} [onSuccess] - The handler to call when this
* {@link Promise} has been successfully resolved.
* @param {function} [onFailure] - The handler to call when this
* {@link Promise} has been rejected.
* @returns {Promise} A new {@link Promise} resolving to the return value
* of the called handler
* @function module:$promise.Promise#then
*/
'then': { enumerable: true, configurable: false, value: function() {
return deferred.promise.then.apply(deferred.promise, arguments);
}},
/**
* Appends a rejection handler to this {@link Promise}, and returns a
* **new** promise resolving to the return value of the called handler.
*
* This is equivalent to calling `then(null, onFailure)`.
*
* @param {function} [onFailure] - The handler to call when this
* {@link Promise} has been rejected.
* @returns {Promise} A new {@link Promise} resolving to the return value
* of the called handler
* @function module:$promise.Promise#catch
*/
'catch': { enumerable: true, configurable: false, value: function() {
return deferred.promise.catch.apply(deferred.promise, arguments);
}}
});

@@ -257,22 +270,31 @@

/* Convert our elements into real promises */
var promises = [];
for (var i in iterable) {
promises.push(PromiseImpl.resolve(iterable[i]));
/* If we have no promises, just resolve */
var deferred = new Deferred();
if (iterable.length == 0) {
deferred.resolve([]);
return deferred.promise;
}
/* If we have no promises, just resolve */
if (promises.length == 0) return PromiseImpl.resolve([]);
/* A deferred, list of results, and pending count */
var deferred = new Deferred();
var results = new Array(promises.length);
var pending = promises.length;
var results = new Array(iterable.length);
var pending = iterable.length;
/* Instruct all our promises */
for (var i = 0; i < promises.length; i++) {
for (var i = 0; i < iterable.length; i++) {
(function(i) {
promises[i].then(function(success) {
/* On success, remember result */
results[i] = success;
var current = iterable[i];
if (current && (typeof(current.then) === 'function')) {
current.then(function(success) {
/* On success, remember result */
results[i] = success;
/* If no more, resolve the deferred */
if ((-- pending) == 0) {
deferred.resolve(results);
}
}, function(failure) {
/* Reject immediately */
deferred.reject(failure);
});
} else {
results[i] = current;
/* If no more, resolve the deferred */

@@ -282,6 +304,3 @@ if ((-- pending) == 0) {

}
}, function(failure) {
/* Reject immediately */
deferred.reject(failure);
});
}
})(i);

@@ -317,4 +336,5 @@ }

for (var i in iterable) {
PromiseImpl.resolve(iterable[i])
.then(function(success) {
var current = iterable[i];
if (current && (typeof(current.then) === 'function')) {
current.then(function(success) {
deferred.resolve(success);

@@ -324,2 +344,5 @@ }, function(failure) {

});
} else {
deferred.resolve(current);
}
}

@@ -347,9 +370,13 @@

value: function(success) {
return new PromiseImpl(function(resolve, reject) {
if (success && success.then && (typeof(success.then) === 'function')) {
success.then(resolve, reject);
} else {
resolve(success);
}
}, true);
var deferred = new Deferred();
if (success && typeof(success.then) === 'function') {
success.then(function(success) {
deferred.resolve(success)
}, function(failure) {
deferred.reject(failure);
});
} else {
deferred.resolve(success);
}
return deferred.promise;
}

@@ -369,5 +396,5 @@ });

value: function(failure) {
return new PromiseImpl(function(resolve, reject) {
reject(failure);
}, true);
var deferred = new Deferred();
deferred.reject(failure);
return deferred.promise;
}

@@ -400,5 +427,5 @@ });

this.message = message;
if (this.stack) {
var stack = this.stack;
stack = stack.replace(new RegExp("^" + this.name + "\n"), "");
var stack = this.stack || new Error().stack;
if (stack) {
stack = stack.replace(new RegExp("^(Error|" + this.name + ")\n"), "");
this.stack = this.name + ": " + this.message + "\n" + stack;

@@ -571,2 +598,5 @@ }

/* Listeners (should contain only "define") */
var listeners = { define: [] };
/* Static list of known modules */

@@ -731,5 +761,16 @@ var modules = {

/* Remember and return a new module */
modules[name] = new Module(name, dependencies, constructor);
return modules[name];
/* Create and remember our new module */
var module = modules[name] = new Module(name, dependencies, constructor);
if (module.$$dynamic) return module;
/* Notify all "define" listeners */
for (var i in listeners['define']) {
try {
listeners['define'][i](module);
} catch (error) {
console.error("Error notifying listener", error);
}
}
return module;
};

@@ -893,46 +934,62 @@

/* Return a promise */
var promise = new Promise(function(resolveCallback, rejectCallback) {
/* Create a deferred and *IMMEDIATELY* cache the promise */
var deferred = new Deferred();
if (module.name && (! module.$$dynamic)) {
cache[module.name] = deferred.promise;
}
/* Set a timeout */
var timeoutMillis = timeout - (dependencyStack.length * 10);
var timeoutId = global.setTimeout(function() {
rejectCallback(new EsquireError("Timeout reached waiting for module '" + module.name + "'", cloneStack));
}, timeoutMillis < 50 ? 50 : timeoutMillis);
/* Set a timeout, after which module construction will fail */
var timeoutMillis = timeout - (cloneStack.length * 5);
if (timeoutMillis < 50) timeoutMillis = 50;
var timeoutId = global.setTimeout(function() {
var error = new EsquireError("Timeout reached waiting for module '" + module.name + "'", cloneStack);
deferred.reject(error);
}, timeoutMillis);
/* Clear timeouts and resolve/reject */
var resolve = function(success) { global.clearTimeout(timeoutId); resolveCallback(success) };
var reject = function(failure) { global.clearTimeout(timeoutId); rejectCallback (failure) };
/* Clear timeouts and resolve */
var resolveCallback = function(success) {
global.clearTimeout(timeoutId);
/* When all parameters have been resolved... */
Promise.all(parameters).then(
function(success) {
try {
/* ... then call the constructor */
var result = module.constructor.apply(module, success);
Promise.resolve(result).then(
function(success) { resolve(success) },
function(failure) {
/* On failure from a promise, just make sure we wrap the error */
reject(new ModuleConstructorError(module.name, failure, cloneStack));
reject(failure);
}
);
/* Cache the resolved value */
if (module.name && (! module.$$dynamic)) {
cache[module.name] = success;
}
} catch (error) {
/* Errors from invoking the constructor head down here */
reject(new ModuleConstructorError(module.name, error, cloneStack));
/* Resolve the deferred */
deferred.resolve(success);
};
/* Clear timeouts and reject */
var rejectCallback = function(failure) {
global.clearTimeout(timeoutId);
deferred.reject(failure);
};
/* When all parameters have been resolved... */
Promise.all(parameters).then(
function(success) {
try {
/* ... then call the constructor */
var result = module.constructor.apply(module, success);
if (result && (typeof(result.then) === 'function')) {
result.then(resolveCallback, function(failure) {
var error = new ModuleConstructorError(module.name, failure, cloneStack);
rejectCallback(error);
});
} else {
resolveCallback(result);
}
}, function(failure) {
reject(failure);
} catch (error) {
/* Errors from invoking the constructor head down here */
rejectCallback(new ModuleConstructorError(module.name, error, cloneStack));
}
);
});
}, function(failure) {
rejectCallback(failure);
}
);
if (module.name && (! module.$$dynamic)) {
cache[module.name] = promise;
}
return promise;
/* Return the promise */
return deferred.promise;

@@ -1046,4 +1103,2 @@ }

//console.log("SHOULD INJECT", args.function.toString());
/* Create a fake "null" module and return its value */

@@ -1054,3 +1109,2 @@ var module = new Module(null, args.arguments, args.function);

} catch (error) {
//console.log("GOT ERROR", error);
return Promise.reject(error);

@@ -1129,2 +1183,21 @@ }

return null;
}},
/**
* Set up notifications for events.
*
* The only event supported currently is the `define` event.
*
* @static
* @function on
* @param {string} event - The name of the event to listen for.
* @param {function} callback - The callback function to be invoked.
* @memberof Esquire
* @returns {Esquire} The static {@link Esquire} class.
*/
"on": { enumerable: true, configurable: false, value: function(event, listener) {
if (!(typeof(event) === 'string')) throw new EsquireError("Event name must be a string");
if (!(typeof(listener) === 'function')) throw new EsquireError("Listener must be a function");
if (event === 'define') listeners.define.push(listener);
return Esquire;
}}

@@ -1131,0 +1204,0 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc