UNPKG

nextgen-events

Version:

The next generation of events handling for javascript! New: abstract away the network!

2 lines 131 kB
(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var t;if(typeof window!=="undefined"){t=window}else if(typeof global!=="undefined"){t=global}else if(typeof self!=="undefined"){t=self}else{t=this}t.createTeaTime=e()}})(function(){var e,t,r;return function e(t,r,n){function i(o,a){if(!r[o]){if(!t[o]){var l=typeof require=="function"&&require;if(!a&&l)return l(o,!0);if(s)return s(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var c=r[o]={exports:{}};t[o][0].call(c.exports,function(e){var r=t[o][1][e];return i(r?r:e)},c,c.exports,e,t,r,n)}return r[o].exports}var s=typeof require=="function"&&require;for(var o=0;o<n.length;o++)i(n[o]);return i}({1:[function(e,t,r){"use strict";function n(e,t){if(!t){t=Object.create(n.prototype,{teaTime:{value:e,enumerable:true}})}document.querySelector("body").insertAdjacentHTML("beforeend",'<div class="tea-time-classic-reporter" style="background-color:black;color:white"></div>');t.container=document.querySelector("div.tea-time-classic-reporter");t.teaTime.on("enterSuite",n.enterSuite.bind(t));t.teaTime.on("ok",n.ok.bind(t));t.teaTime.on("fail",n.fail.bind(t));t.teaTime.on("optionalFail",n.optionalFail.bind(t));t.teaTime.on("skip",n.skip.bind(t));t.teaTime.on("report",n.report.bind(t));t.teaTime.on("errorReport",n.errorReport.bind(t));return t}t.exports=n;function i(){(document.querySelector("div.tea-time-classic-reporter p:last-child")||document.querySelector("div.tea-time-classic-reporter h4:last-child")||document.querySelector("div.tea-time-classic-reporter pre:last-child")).scrollIntoView()}function s(e){return"margin-left:"+(1+2*e)+"%;"}var o="color:grey;";var a="color:green;";var l="color:red;";var u="color:brown;";var c="color:blue;";var f="color:grey;";var p="color:yellow;";var h="color:red;";var d="color:brown;font-weight:bold;";var v="color:red;font-weight:bold;";var y="background-color:red;color:white;font-weight:bold;";var m="background-color:green;color:white;font-weight:bold;";var g="background-color:red;color:white;font-weight:bold;";n.enterSuite=function e(t,r){this.container.insertAdjacentHTML("beforeend",'<h4 class="tea-time-classic-reporter" style="'+s(r)+'">'+t+"</h4>");i()};n.ok=function e(t,r,n,o){var l="✔ "+t;if(!o){l+=' <span style="'+f+'">('+n+"ms)</span>"}else if(o===1){l+=' <span style="'+p+'">('+n+"ms)</span>"}else{l+=' <span style="'+h+'">('+n+"ms)</span>"}this.container.insertAdjacentHTML("beforeend",'<p class="tea-time-classic-reporter" style="'+a+s(r)+'">'+l+"</p>");i()};n.fail=function e(t,r,n,o,a){var u="✘ "+t;if(n!==undefined){if(!o){u+=' <span style="'+f+'">('+n+"ms)</span>"}else if(o===1){u+=' <span style="'+p+'">('+n+"ms)</span>"}else{u+=' <span style="'+h+'">('+n+"ms)</span>"}}this.container.insertAdjacentHTML("beforeend",'<p class="tea-time-classic-reporter" style="'+l+s(r)+'">'+u+"</p>");i()};n.optionalFail=function e(t,r,n,o,a){var l="✘ "+t;if(n!==undefined){if(!o){l+=' <span style="'+f+'">('+n+"ms)</span>"}else if(o===1){l+=' <span style="'+p+'">('+n+"ms)</span>"}else{l+=' <span style="'+h+'">('+n+"ms)</span>"}}this.container.insertAdjacentHTML("beforeend",'<p class="tea-time-classic-reporter" style="'+u+s(r)+'">'+l+"</p>");i()};n.skip=function e(t,r){var n="· "+t;this.container.insertAdjacentHTML("beforeend",'<p class="tea-time-classic-reporter" style="'+c+s(r)+'">'+n+"</p>");i()};n.report=function e(t,r,n,f,p){this.container.insertAdjacentHTML("beforeend","<hr />"+'<p class="tea-time-classic-reporter" style="font-weight:bold;'+a+s(1)+'">'+t+" passing "+(p<2e3?'<span style="'+o+'">('+Math.round(p)+"ms)</span>":'<span style="'+o+'">('+Math.round(p/1e3)+"s)</span>")+"</p>"+'<p class="tea-time-classic-reporter" style="font-weight:bold;'+l+s(1)+'">'+r+" failing</p>"+(n?'<p class="tea-time-classic-reporter" style="font-weight:bold;'+u+s(1)+'">'+n+" opt failing</p>":"")+(f?'<p class="tea-time-classic-reporter" style="font-weight:bold;'+c+s(1)+'">'+f+" pending</p>":""));i()};n.errorReport=function e(t){var r,n,o="";o+='<h4 class="tea-time-classic-reporter" style="'+v+s(0)+'">== Errors ==</h4>';for(r=0;r<t.length;r++){n=t[r];o+='<p class="tea-time-classic-reporter" style="'+(n.optional?d:v)+s(1)+'">'+(r+1)+" ) ";switch(n.type){case"test":if(n.error.testTimeout){o+='<span style="'+y+'">TEST TIMEOUT</span> '}break;case"setup":o+='<span style="'+y+'">SETUP HOOK</span> ';break;case"teardown":o+='<span style="'+y+'">TEARDOWN HOOK</span> ';break;case"suiteSetup":o+='<span style="'+y+'">SUITE SETUP HOOK</span> ';break;case"suiteTeardown":o+='<span style="'+y+'">SUITE TEARDOWN HOOK</span> ';break}if(n.error.uncaught){o+='<span style="'+y+'">UNCAUGHT EXCEPTION</span> '}o+=n.name;o+="</p>";o+=this.reportOneError(n.error)}this.container.insertAdjacentHTML("beforeend","<hr />"+o);i()};n.prototype.reportOneError=function e(t){var r="";if("expected"in t&&"actual"in t){r+='<p class="tea-time-classic-reporter" style="'+s(2)+'">'+'<span style="'+m+'">expected</span><span style="'+g+'">actual</span>'+"</p>";r+='<pre class="tea-time-classic-reporter"; style="'+s(2)+'">';r+=this.teaTime.htmlColorDiff(t.actual,t.expected);r+="</pre>"}r+='<pre class="tea-time-classic-reporter" style="'+s(2)+'">'+this.teaTime.inspect.inspectError({style:"html"},t)+"</pre>";return r}},{}],2:[function(e,t,r){"use strict";function n(e,t){if(!t){t=Object.create(n.prototype,{teaTime:{value:e,enumerable:true}})}t.teaTime.on("ok",n.ok.bind(t));t.teaTime.on("fail",n.fail.bind(t));t.teaTime.on("optionalFail",n.optionalFail.bind(t));t.teaTime.on("skip",n.skip.bind(t));t.teaTime.on("report",n.report.bind(t));return t}t.exports=n;n.ok=function e(t,r,n,i){console.log("OK:",t,"("+n+")")};n.fail=function e(t,r,n,i,s){console.log("Fail:",t,n!==undefined?"("+n+")":"")};n.optionalFail=function e(t,r,n,i,s){console.log("Opt fail:",t,n!==undefined?"("+n+")":"")};n.skip=function e(t,r){console.log("Pending:",t)};n.report=function e(t,r,n,i){console.log("Report -- ok:",t," fail:",r," opt fail:",n," pending:",i)}},{}],3:[function(e,t,r){"use strict";function n(e,t){if(!t){t=Object.create(n.prototype,{teaTime:{value:e,enumerable:true}})}t.teaTime.on("ready",{fn:n.ready.bind(t),async:true});t.teaTime.on("run",n.forward.bind(t,"run"));t.teaTime.on("enterSuite",n.forward.bind(t,"enterSuite"));t.teaTime.on("exitSuite",n.forward.bind(t,"exitSuite"));t.teaTime.on("enterTest",n.forward.bind(t,"enterTest"));t.teaTime.on("exitTest",n.forward.bind(t,"exitTest"));t.teaTime.on("ok",n.forward.bind(t,"ok"));t.teaTime.on("fail",n.forward.bind(t,"fail"));t.teaTime.on("optionalFail",n.forward.bind(t,"optionalFail"));t.teaTime.on("skip",n.forward.bind(t,"skip"));t.teaTime.on("report",n.forward.bind(t,"report"));t.teaTime.on("errorReport",n.forward.bind(t,"errorReport"));t.teaTime.on("exit",n.exit.bind(t,"exit"));return t}t.exports=n;n.ready=function e(t){var r=this;this.ws=new WebSocket("ws://127.0.0.1:7357/"+this.teaTime.token);this.ws.onopen=function e(){n.forward.call(r,"ready");console.log("Websocket opened!");t()};this.ws.onclose=function e(){console.log("Websocket closed!")}};n.forward=function e(t){var r=Array.prototype.slice.call(arguments,1);this.teaTime.prepareSerialize(r);this.ws.send(JSON.stringify({event:t,args:r}))};n.exit=function e(t){n.forward.call(this,"exit");this.ws.close()}},{}],4:[function(e,t,r){"use strict";var n=e("./tea-time.js");var i=e("./diff.js");var s=e("./htmlColorDiff.js");var o=e("string-kit/lib/inspect.js");var a=e("dom-kit");var l=e("url");function u(){var t={microTimeout:function(e){setTimeout(e,0)},onceUncaughtException:function(e){window.onerror=function(t,r,n,i,s){window.onerror=function(){};e(s);return true}},offUncaughtException:function(){window.onerror=function(){}},allowConsole:true};n.populateOptionsWithArgs(t,l.parse(window.location.href,true).query);window.teaTime=n.create(t);window.teaTime.init();window.teaTime.diff=i;window.teaTime.htmlColorDiff=s;window.teaTime.inspect=o;window.teaTime.prepareSerialize=c;window.teaTime.reporters={console:e("./browser-reporters/console.js"),classic:e("./browser-reporters/classic.js"),websocket:e("./browser-reporters/websocket.js")};t.reporters.forEach(function(e){window.teaTime.reporters[e](window.teaTime)});if(t.ws){window.teaTime.ws=true}return window.teaTime}t.exports=u;function c(e){var t,r,n,i;if(!e||typeof e!=="object"){return}if(Array.isArray(e)){for(t=0,r=e.length;t<r;t++){c(e[t])}return}i=e.__proto__&&e.__proto__.constructor.name;if(i&&i!=="Object"){e.__prototype=i}if(e instanceof Error){Object.defineProperties(e,{__prototype:{value:e.constructor.name,enumerable:true,writable:true},name:{value:e.name,enumerable:true,writable:true},message:{value:e.message,enumerable:true,writable:true},type:{value:e.type||e.constructor.name,enumerable:true,writable:true},stack:{value:e.stack,enumerable:true,writable:true}})}n=Object.keys(e);for(t=0,r=n.length;t<r;t++){c(e[n[t]])}}u();a.ready(function(){window.teaTime.run()})},{"./browser-reporters/classic.js":1,"./browser-reporters/console.js":2,"./browser-reporters/websocket.js":3,"./diff.js":5,"./htmlColorDiff.js":6,"./tea-time.js":7,"dom-kit":40,"string-kit/lib/inspect.js":47,url:23}],5:[function(e,t,r){"use strict";var n=e("string-kit/lib/inspect.js");var i=e("diff");var s={minimal:true,depth:10,sort:true};function o(e,t){var r="",n=o.raw(e,t,true);n.forEach(function(e){r+=e.value.replace(/^(?!$)/gm,function(){if(e.added){return"++"}else if(e.removed){return"--"}else{return" "}})});return r}t.exports=o;o.raw=function e(t,r,o){var a,l=0;var u=n.inspect(s,t);var c=n.inspect(s,r);if(!o){a=i.diffChars(u,c);a.forEach(function(e){if(e.added||e.removed){l+=15+e.value.length}});if(l<80){return a}}a=i.diffLines(u,c);return a}},{diff:34,"string-kit/lib/inspect.js":47}],6:[function(e,t,r){"use strict";var n=e("./diff.js").raw;t.exports=function e(t,r){var i="",s=n(t,r);s.forEach(function(e){if(e.added){i+=e.value.replace(/^(\s*)(\S(?:[^\n]*\S)?)(\s*)$/gm,function(e,t,r,n){return t+'<span style="background-color:green;color:white">'+r+"</span>"+n})}else if(e.removed){i+=e.value.replace(/^(\s*)(\S(?:[^\n]*\S)?)(\s*)$/gm,function(e,t,r,n){return t+'<span style="background-color:red;color:white">'+r+"</span>"+n})}else{i+='<span style="color:grey">'+e.value+"</span>"}});return i}},{"./diff.js":5}],7:[function(e,t,r){(function(r){"use strict";var n=e("async-kit");var i=e("nextgen-events");var s=e("async-try-catch").try;function o(){throw new Error("Use TeaTime.create() instead")}o.prototype=Object.create(i.prototype);o.prototype.constructor=o;t.exports=o;o.create=function e(t){var r=Object.create(o.prototype,{timeout:{value:t.timeout||2e3,writable:true,enumerable:true},slowTime:{value:t.slowTime||75,writable:true,enumerable:true},suite:{value:o.createSuite(),enumerable:true},grep:{value:Array.isArray(t.grep)?t.grep:[],writable:true,enumerable:true},allowConsole:{value:!!t.allowConsole,writable:true,enumerable:true},bail:{value:!!t.bail,writable:true,enumerable:true},skipOptional:{value:!!t.skipOptional,writable:true,enumerable:true},token:{value:t.token||null,writable:true,enumerable:true},acceptTokens:{value:t.acceptTokens||null,writable:true,enumerable:true},startTime:{value:0,writable:true,enumerable:true},testCount:{value:0,writable:true,enumerable:true},done:{value:0,writable:true,enumerable:true},ok:{value:0,writable:true,enumerable:true},fail:{value:0,writable:true,enumerable:true},optionalFail:{value:0,writable:true,enumerable:true},skip:{value:0,writable:true,enumerable:true},errors:{value:[],enumerable:true},microTimeout:{value:t.microTimeout,enumerable:true},onceUncaughtException:{value:t.onceUncaughtException,enumerable:true},offUncaughtException:{value:t.offUncaughtException,enumerable:true}});Object.defineProperties(r,{registerStack:{value:[r.suite],writable:true,enumerable:true}});return r};o.populateOptionsWithArgs=function e(t,r){var n,i,s;if(!t.reporters){t.reporters=["classic"]}if(!t.clientReporters){t.clientReporters=["classic"]}if(r.console!==undefined){t.allowConsole=r.console}else if(r.c!==undefined){t.allowConsole=r.c}if(r.b||r.bail){t.bail=true}if(r["skip-optional"]||r.O){t.skipOptional=true}if(r.timeout&&(s=parseInt(r.timeout,10))){t.timeout=s}else if(r.t&&(s=parseInt(r.t,10))){t.timeout=s}if(r.slow&&(s=parseInt(r.slow,10))){t.slowTime=s}else if(r.s&&(s=parseInt(r.s,10))){t.slowTime=s}if(r.reporter){if(!Array.isArray(r.reporter)){r.reporter=[r.reporter]}t.reporters=r.reporter;if(r.R){if(!Array.isArray(r.R)){r.R=[r.R]}t.reporters=r.reporter.concat(r.R)}}else if(r.R){if(!Array.isArray(r.R)){r.R=[r.R]}t.reporters=r.R}if(r.clientReporter){if(!Array.isArray(r.clientReporter)){r.clientReporter=[r.clientReporter]}t.clientReporters=r.clientReporter}t.grep=[];t.sourceGrep=[];if(r.g){if(!Array.isArray(r.g)){r.g=[r.g]}for(n=0,i=r.g.length;n<i;n++){t.grep.push(new RegExp(r.g[n],"i"));t.sourceGrep.push(r.g[n])}}if(r.grep){if(!Array.isArray(r.grep)){r.grep=[r.grep]}for(n=0,i=r.grep.length;n<i;n++){t.grep.push(new RegExp(r.grep[n],"i"));t.sourceGrep.push(r.grep[n])}}if(r.token){t.token=r.token}};o.prototype.init=function e(t){r.suite=r.describe=r.context=o.registerSuite.bind(this);r.test=r.it=r.specify=o.registerTest.bind(this);r.test.skip=o.registerSkipTest.bind(this);r.test.optional=o.registerOptionalTest.bind(this);r.test.opt=o.registerOptionalTest.bind(this);r.test.next=o.registerOptionalTest.bind(this);r.setup=r.beforeEach=o.registerHook.bind(this,"setup");r.teardown=r.afterEach=o.registerHook.bind(this,"teardown");r.suiteSetup=r.before=o.registerHook.bind(this,"suiteSetup");r.suiteTeardown=r.after=o.registerHook.bind(this,"suiteTeardown");if(!this.allowConsole){o.disableConsole()}};o.disableConsole=function e(){console.log=console.error=console.assert=console.info=console.dir=console.warn=console.trace=console.time=console.timeEnd=function(){}};o.createSuite=function e(t){var r=[];Object.defineProperties(r,{name:{value:t},parent:{value:null,writable:true},suiteSetup:{value:[]},suiteTeardown:{value:[]},setup:{value:[]},teardown:{value:[]}});return r};o.sortSuite=function e(t){t.sort(function(e,t){var r=Array.isArray(e)?1:0;var n=Array.isArray(t)?1:0;if(r-n){return r-n}return e.order-t.order})};o.prototype.run=function e(t){var r=this,n=false;o.sortSuite(this.suite);this.emit("ready",function(){r.emit("run",r.testCount);var e=function(){if(n){return}if(typeof t==="function"){t()}};r.startTime=Date.now();r.runSuite(r.suite,0,function(){r.emit("report",r.ok,r.fail,r.optionalFail,r.skip,Date.now()-r.startTime);if(r.fail+r.optionalFail){r.emit("errorReport",r.errors)}r.emit("exit",e);setTimeout(e,1e4)})})};o.prototype.runSuite=function e(t,r,n){var i=this;if(r){i.emit("enterSuite",t.name,r-1)}var s=function(e){if(r){i.emit("exitSuite",t.name,r-1)}n(e)};this.runHooks(t.suiteSetup,r,function(e){if(e){i.patchError(e);i.errors.push({name:e.hookFn.hookName+"["+e.hookFn.hookType+"]",type:e.hookFn.hookType,fn:e.hookFn,error:e});i.failSuite(t,r,"suiteSetup",e.hookFn,e);i.runHooks(t.suiteTeardown,r,function(t){s(e)});return}i.runSuiteTests(t,r,function(e){i.runHooks(t.suiteTeardown,r,function(t){if(e){s(e)}else if(t){i.patchError(t);i.errors.push({name:t.hookFn.hookName+"["+t.hookFn.hookType+"]",type:t.hookFn.hookType,fn:t.hookFn,error:t});s(t)}else{s()}})})})};o.prototype.runSuiteTests=function e(t,r,i){var s=this;n.foreach(t,function(e,n){if(Array.isArray(e)){s.runSuite(e,r+1,n);return}s.runTest(t,r,e,n)}).fatal(s.bail).exec(i)};o.prototype.failSuite=function e(t,r,n,i,s){var o,a;for(o=0,a=t.length;o<a;o++){if(Array.isArray(t[o])){this.failSuite(t[o],r+1,n,i,s)}this.done++;this.fail++;this.emit("fail",t[o].testName,r,undefined,undefined,s)}};o.prototype.runTest=function e(t,r,n,i){var s=this;s.testInProgress=n;if(typeof n!=="function"){s.done++;s.skip++;s.emit("skip",n.testName,r);i();return}var a=t,l=t.setup,u=t.teardown;while(a.parent){a=a.parent;l=a.setup.concat(l);u=a.teardown.concat(u)}var c=n.length?o.asyncTest.bind(s):o.syncTest.bind(s);var f=function(e,t,o,a){if(e){s.done++;s.patchError(e);s.errors.push({name:(e.hookFn?e.hookFn.hookName+"["+e.hookFn.hookType+"] ":"")+n.testName,type:a,fn:n,optional:n.optional,error:e});if(n.optional){s.optionalFail++;s.emit("optionalFail",n.testName,r,t,o,e)}else{s.fail++;s.emit("fail",n.testName,r,t,o,e)}i(e)}else{s.done++;s.ok++;s.emit("ok",n.testName,r,t,o);i()}};s.runHooks(l,r,function(e){if(e){s.runHooks(u,r,function(t){f(e,undefined,undefined,"setup")});return}s.emit("enterTest",n.testName,r);c(n,function(e,t,i){s.emit("exitTest",n.testName,r);s.runHooks(u,r,function(r,s){if(e){f(e,t,i,"test",n)}else if(r){f(r,t,i,"teardown",s[s.length-1][2])}else{f(undefined,t,i)}})})})};o.syncTest=function e(t,r){var n,i,s=this.slowTime;r=this.freshCallback(r);var o={timeout:function(){},slow:function(e){s=e}};try{n=Date.now();t.call(o);i=Date.now()-n}catch(e){i=Date.now()-n;r(e,i,Math.floor(i/s));return}r(undefined,i,Math.floor(i/s))};o.asyncTest=function e(t,r){var n=this,i,o,a=false,l=null,u=n.slowTime;r=this.freshCallback(r);var c={timeout:function(e){if(a){return}if(l!==null){clearTimeout(l);l=null}l=setTimeout(function(){var e=new Error("Test timeout (local)");e.testTimeout=true;p(e)},e)},slow:function(e){u=e}};var f=function e(t){t.uncaught=true;p(t)};var p=function e(t){n.offUncaughtException(f);if(a){return}o=Date.now()-i;a=true;if(l!==null){clearTimeout(l);l=null}r(t,o,Math.floor(o/u))};l=setTimeout(function(){var e=new Error("Test timeout");e.testTimeout=true;p(e)},n.timeout);s(function(){i=Date.now();t.call(c,p)}).catch(function(e){p(e)});this.onceUncaughtException(f)};o.prototype.runHooks=function e(t,r,i){var s=this;n.foreach(t,function(e,t){var n=e.length?o.asyncHook.bind(s):o.syncHook.bind(s);s.emit("enterHook",e.hookType,e.hookName,r);n(e,function(n){s.emit("exitHook",e.hookType,e.hookName,r);if(n){n.hookFn=e}t(n)})}).fatal(true).exec(i)};o.syncHook=function e(t,r){r=this.freshCallback(r);try{t()}catch(e){r(e);return}r()};o.asyncHook=function e(t,r){var n=this,i=false;r=this.freshCallback(r);var o=function e(t){t.uncaught=true;a(t)};var a=function e(t){n.offUncaughtException(o);if(i){return}i=true;r(t)};s(function(){t(a)}).catch(function(e){a(e)});this.onceUncaughtException(o)};o.registerSuite=function e(t,r){if(!t||typeof t!=="string"||typeof r!=="function"){throw new Error("Usage is suite( name , fn )")}var n=this.registerStack[this.registerStack.length-1];var i=o.createSuite(t);this.registerStack.push(i);r();this.registerStack.pop();if(!i.length){return}Object.defineProperties(i,{order:{value:n.length}});o.sortSuite(i);n.push(i);Object.defineProperty(i,"parent",{value:n})};o.registerTest=function e(t,r,n){var i,s,o,a,l,u;if(!t||typeof t!=="string"){throw new Error("Usage is test( name , [fn] , [optional] )")}u=this.registerStack[this.registerStack.length-1];for(i=0,s=this.grep.length;i<s;i++){l=false;if(t.match(this.grep[i])){continue}for(o=1,a=this.registerStack.length;o<a;o++){if(this.registerStack[o].name.match(this.grep[i])){l=true;break}}if(!l){return}}this.testCount++;if(typeof r!=="function"){r={}}Object.defineProperties(r,{testName:{value:t},optional:{value:!!n},order:{value:u.length}});u.push(r)};o.registerSkipTest=function e(t){return o.registerTest.call(this,t)};o.registerOptionalTest=function e(t,r){return this.skipOptional?o.registerTest.call(this,t):o.registerTest.call(this,t,r,true)};o.registerHook=function e(t,r,n){var i;if(typeof r==="function"){n=r;r=undefined}else if(typeof n!=="function"){throw new Error("Usage is hook( [name] , fn )")}Object.defineProperties(n,{hookName:{value:r||n.name||"[no name]"},hookType:{value:t}});i=this.registerStack[this.registerStack.length-1];i[t].push(n)};o.prototype.freshCallback=function e(t){var r=this;return function(){var e=arguments;r.microTimeout(function(){t.apply(r,e)})}};o.prototype.patchError=function e(t){var r,n,i;if(!t.stack){return}i=t.stack;if(!Array.isArray(i)){i=t.stack.split("\n")}for(r=0,n=i.length;r<n;r++){if(i[r].match(/(^|\/)tea-time\.(min\.)?js/)){i=i.slice(0,r);break}}t.stack=i.join("\n")}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"async-kit":8,"async-try-catch":13,"nextgen-events":42}],8:[function(e,t,r){"use strict";var n=e("./core.js");t.exports=n;n.wrapper=e("./wrapper.js");n.exit=e("./exit.js");var i=e("./safeTimeout.js");n.setSafeTimeout=i.setSafeTimeout;n.clearSafeTimeout=i.clearSafeTimeout},{"./core.js":9,"./exit.js":10,"./safeTimeout.js":11,"./wrapper.js":12}],9:[function(e,t,r){"use strict";var n=e("nextgen-events");var i=e("tree-kit/lib/extend.js");var s={};t.exports=s;s.AsyncError=function e(t){Error.call(this);Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor);this.message=t};s.AsyncError.prototype=Object.create(Error.prototype);s.AsyncError.prototype.constructor=s.AsyncError;s.Plan=function e(){throw new Error("[async] Cannot create an async Plan object directly")};s.Plan.prototype.constructor=s.Plan;var o={parallelLimit:{value:1,writable:true,enumerable:true,configurable:true},raceMode:{value:false,writable:true,enumerable:true,configurable:true},waterfallMode:{value:false,writable:true,enumerable:true,configurable:true},waterfallTransmitError:{value:false,writable:true,enumerable:true,configurable:true},whileAction:{value:undefined,writable:true,enumerable:true,configurable:true},whileActionBefore:{value:false,writable:true,enumerable:true,configurable:true},errorsAreFatal:{value:true,writable:true,enumerable:true,configurable:true},returnMapping1to1:{value:false,writable:true,enumerable:true,configurable:true},jobsData:{value:{},writable:true,enumerable:true},jobsKeys:{value:[],writable:true,enumerable:true},jobsUsing:{value:undefined,writable:true,enumerable:true},jobsTimeout:{value:undefined,writable:true,enumerable:true},useSafeTimeout:{value:false,writable:true,enumerable:true},returnLastJobOnly:{value:false,writable:true,enumerable:true},defaultAggregate:{value:undefined,writable:true,enumerable:true},returnAggregate:{value:false,writable:true,enumerable:true},transmitAggregate:{value:false,writable:true,enumerable:true},usingIsIterator:{value:false,writable:true,enumerable:true},thenAction:{value:undefined,writable:true,enumerable:true},catchAction:{value:undefined,writable:true,enumerable:true},finallyAction:{value:undefined,writable:true,enumerable:true},asyncEventNice:{value:-20,writable:true,enumerable:true},maxRetry:{value:0,writable:true,enumerable:true},retryTimeout:{value:0,writable:true,enumerable:true},retryMultiply:{value:1,writable:true,enumerable:true},retryMaxTimeout:{value:Infinity,writable:true,enumerable:true},execMappingMinInputs:{value:0,writable:true,enumerable:true},execMappingMaxInputs:{value:100,writable:true,enumerable:true},execMappingCallbacks:{value:["finally"],writable:true,enumerable:true},execMappingAggregateArg:{value:false,writable:true,enumerable:true},execMappingMinArgs:{value:0,writable:true,enumerable:true},execMappingMaxArgs:{value:101,writable:true,enumerable:true},execMappingSignature:{value:"( [finallyCallback] )",writable:true,enumerable:true},locked:{value:false,writable:true,enumerable:true}};s.do=function e(t){var r=Object.create(s.Plan.prototype,o);Object.defineProperties(r,{execInit:{value:a.bind(r)},execNext:{value:l.bind(r)},execCallback:{value:u},execLoopCallback:{value:c},execFinal:{value:f.bind(r)}});r.do(t);return r};s.parallel=function e(t){var r=Object.create(s.Plan.prototype,o);Object.defineProperties(r,{parallelLimit:{value:Infinity,writable:true,enumerable:true},execInit:{value:a.bind(r)},execNext:{value:l.bind(r)},execCallback:{value:u},execLoopCallback:{value:c},execFinal:{value:f.bind(r)}});r.do(t);return r};s.series=function e(t){var r=Object.create(s.Plan.prototype,o);Object.defineProperties(r,{parallelLimit:{value:1,enumerable:true},execInit:{value:a.bind(r)},execNext:{value:l.bind(r)},execCallback:{value:u},execLoopCallback:{value:c},execFinal:{value:f.bind(r)}});r.do(t);return r};s.race=function e(t){var r=Object.create(s.Plan.prototype,o);Object.defineProperties(r,{raceMode:{value:true,enumerable:true},parallelLimit:{value:Infinity,writable:true,enumerable:true},errorsAreFatal:{value:false,writable:true,enumerable:true},execInit:{value:a.bind(r)},execNext:{value:l.bind(r)},execCallback:{value:u},execLoopCallback:{value:c},execFinal:{value:f.bind(r)}});r.returnLastJobOnly=true;r.do(t);return r};s.waterfall=function e(t){var r=Object.create(s.Plan.prototype,o);Object.defineProperties(r,{waterfallMode:{value:true,enumerable:true},waterfallTransmitError:{value:false,writable:true,enumerable:true},parallelLimit:{value:1,enumerable:true},execInit:{value:a.bind(r)},execNext:{value:l.bind(r)},execCallback:{value:u},execLoopCallback:{value:c},execFinal:{value:f.bind(r)}});r.returnLastJobOnly=true;r.do(t);return r};s.foreach=s.forEach=function e(t,r){var n=Object.create(s.Plan.prototype,o);Object.defineProperties(n,{usingIsIterator:{value:true,writable:true,enumerable:true},errorsAreFatal:{value:false,writable:true,enumerable:true},execInit:{value:a.bind(n)},execNext:{value:l.bind(n)},execCallback:{value:u},execLoopCallback:{value:c},execFinal:{value:f.bind(n)}});n.do(t);n.iterator(r);return n};s.map=function e(t,r){var n=Object.create(s.Plan.prototype,o);Object.defineProperties(n,{parallelLimit:{value:Infinity,writable:true,enumerable:true},usingIsIterator:{value:true,writable:true,enumerable:true},errorsAreFatal:{value:false,writable:true,enumerable:true},returnMapping1to1:{value:true,writable:false,enumerable:true},execInit:{value:a.bind(n)},execNext:{value:l.bind(n)},execCallback:{value:u},execLoopCallback:{value:c},execFinal:{value:f.bind(n)}});n.do(t);n.iterator(r);return n};s.reduce=function e(t,r,n){var i=Object.create(s.Plan.prototype,o);Object.defineProperties(i,{parallelLimit:{value:1,writable:false,enumerable:true},usingIsIterator:{value:true,writable:true,enumerable:true},execInit:{value:a.bind(i)},execNext:{value:l.bind(i)},execCallback:{value:u},execLoopCallback:{value:c},execFinal:{value:f.bind(i)}});if(arguments.length<3){n=r;r=undefined;i.execMappingMinInputs=0;i.execMappingMaxInputs=100;i.execMappingCallbacks=["finally"];i.execMappingAggregateArg=true;i.execMappingMinArgs=1;i.execMappingMaxArgs=102;i.execMappingSignature="( aggregateArg, [finallyCallback] )"}i.transmitAggregate=true;i.returnAggregate=true;i.defaultAggregate=r;i.do(t);i.iterator(n);return i};s.while=function e(t){var r=Object.create(s.Plan.prototype,o);Object.defineProperties(r,{waterfallMode:{value:false,enumerable:true},whileAction:{value:undefined,writable:true,enumerable:true},whileActionBefore:{value:true,writable:false,enumerable:true},execInit:{value:a.bind(r)},execNext:{value:l.bind(r)},execCallback:{value:u},execLoopCallback:{value:c},execFinal:{value:f.bind(r)}});r.while(t);return r};s.and=function e(t){var r=Object.create(s.Plan.prototype,o);Object.defineProperties(r,{elseAction:{value:undefined,writable:true,enumerable:true},castToBoolean:{value:false,writable:true,enumerable:true},useLogicAnd:{value:true},execInit:{value:a.bind(r)},execNext:{value:l.bind(r)},execCallback:{value:p},execLoopCallback:{value:c},execFinal:{value:h.bind(r)}});r.do(t);return r};s.or=function e(t){var r=Object.create(s.Plan.prototype,o);Object.defineProperties(r,{elseAction:{value:undefined,writable:true,enumerable:true},castToBoolean:{value:false,writable:true,enumerable:true},useLogicAnd:{value:false},execInit:{value:a.bind(r)},execNext:{value:l.bind(r)},execCallback:{value:p},execLoopCallback:{value:c},execFinal:{value:h.bind(r)}});r.do(t);return r};s.if=function e(t){var r=Object.create(s.Plan.prototype,o);Object.defineProperties(r,{elseAction:{value:true,writable:true,enumerable:true},castToBoolean:{value:true,writable:true,enumerable:true},useLogicAnd:{value:true},execInit:{value:a.bind(r)},execNext:{value:l.bind(r)},execCallback:{value:p},execLoopCallback:{value:c},execFinal:{value:h.bind(r)}});if(t){r.do(t)}return r};s.if.and=s.if;s.if.or=function e(t){var r=Object.create(s.Plan.prototype,o);Object.defineProperties(r,{elseAction:{value:true,writable:true,enumerable:true},castToBoolean:{value:true,writable:true,enumerable:true},useLogicAnd:{value:false},execInit:{value:a.bind(r)},execNext:{value:l.bind(r)},execCallback:{value:p},execLoopCallback:{value:c},execFinal:{value:h.bind(r)}});if(t){r.do(t)}return r};s.callTimeout=function e(t,r,n,i){if(typeof n!=="function"){throw new Error("[async] async.callTimeout(): argument #0 should be a function")}var p=Object.create(s.Plan.prototype,o);Object.defineProperties(p,{returnLastJobOnly:{value:true,enumerable:true},jobsTimeout:{value:t,writable:true,enumerable:true},execInit:{value:a.bind(p)},execNext:{value:l.bind(p)},execCallback:{value:u},execLoopCallback:{value:c},execFinal:{value:f.bind(p)}});var h=[n.bind(i)].concat(Array.prototype.slice.call(arguments,4));p.do([h]);return p.exec(r)};s.Plan.prototype.do=function e(t){if(this.locked){return this}if(t&&typeof t==="object"){this.jobsData=t}else if(typeof t==="function"){this.jobsData=[t];this.returnLastJobOnly=true}else{this.jobsData={}}this.jobsKeys=Object.keys(this.jobsData);return this};s.Plan.prototype.parallel=function e(t){if(this.locked){return this}if(t===undefined||t===true){this.parallelLimit=Infinity}else if(t===false){this.parallelLimit=1}else if(typeof t==="number"){this.parallelLimit=t}return this};s.Plan.prototype.race=function e(t){if(!this.locked){this.raceMode=t||t===undefined?true:false}return this};s.Plan.prototype.waterfall=function e(t){if(!this.locked){this.waterfallMode=t||t===undefined?true:false}return this};s.Plan.prototype.while=function e(t,r){if(this.locked){return this}this.whileAction=t;if(r!==undefined){this.whileActionBefore=r?true:false}return this};s.Plan.prototype.repeat=function e(t){if(this.locked){return this}var r=0;if(typeof t!=="number"){t=parseInt(t)}this.whileActionBefore=true;this.whileAction=function(e,n,i){r++;i(r<=t)};return this};s.Plan.prototype.fatal=function e(t){if(!this.locked){this.errorsAreFatal=t||t===undefined?true:false}return this};s.Plan.prototype.boolean=function e(t){if(!this.locked){this.castToBoolean=t||t===undefined?true:false}return this};s.Plan.prototype.transmitError=function e(t){if(!this.locked){this.waterfallTransmitError=t||t===undefined?true:false}return this};s.Plan.prototype.timeout=function e(t){if(!this.locked){if(typeof t==="number"){this.jobsTimeout=t}else{this.jobsTimeout=undefined}}return this};s.Plan.prototype.safeTimeout=function e(t){if(!this.locked){this.useSafeTimeout=t===undefined?true:!!t}};s.Plan.prototype.retry=function e(t,r,n,i){if(this.locked){return this}if(typeof t==="number"){this.maxRetry=t}if(typeof r==="number"){this.retryTimeout=r}if(typeof n==="number"){this.retryMultiply=n}if(typeof i==="number"){this.retryMaxTimeout=i}return this};s.Plan.prototype.lastJobOnly=function e(t){if(!this.locked){this.returnLastJobOnly=t||t===undefined?true:false}return this};s.Plan.prototype.mapping1to1=function e(t){if(!this.locked){this.returnMapping1to1=t||t===undefined?true:false}return this};s.Plan.prototype.using=function e(t){if(!this.locked){this.jobsUsing=t}return this};s.Plan.prototype.iterator=function e(t){if(this.locked){return this}this.jobsUsing=t;this.usingIsIterator=true;return this};s.Plan.prototype.aggregator=function e(t,r,n){if(!this.locked){return this}this.transmitAggregate=t||t===undefined?true:false;this.returnAggregate=r||r===undefined?true:false;if(arguments.length>2){this.defaultAggregate=n}return this};s.Plan.prototype.usingIterator=function e(t){if(!this.locked){this.usingIsIterator=t||t===undefined?true:false}return this};s.Plan.prototype.nice=function e(t){if(this.locked){return this}if(t===undefined||t===null||t===true){this.asyncEventNice=-1}else if(t===false){this.asyncEventNice=-20}else{this.asyncEventNice=t}return this};s.Plan.prototype.then=function e(t){if(!this.locked){this.thenAction=t}return this};s.Plan.prototype.else=function e(t){if(!this.locked){ this.elseAction=t||true}return this};s.Plan.prototype.catch=function e(t){if(!this.locked){this.catchAction=t||true}return this};s.Plan.prototype.finally=function e(t){if(!this.locked){this.finallyAction=t||true}return this};s.Plan.prototype.clone=function e(){var t=Object.create(s.Plan.prototype,o);i(null,t,this);t.locked=false;return t};s.Plan.prototype.export=function e(t){switch(t){case"execFinally":return this.clone().execFinally.bind(this);case"execThenCatch":return this.clone().execThenCatch.bind(this);case"execThenElse":return this.clone().execThenElse.bind(this);case"execThenElseCatch":return this.clone().execThenElseCatch.bind(this);case"execArgs":return this.clone().execArgs.bind(this);case"execKV":return this.clone().execKV.bind(this);default:return this.clone().exec.bind(this)}};s.Plan.prototype.exec=function e(){var t={inputs:[],callbacks:{}},r=0,n;if(arguments.length<this.execMappingMinArgs){throw new Error("[async] Too few arguments, in this instance, the function signature is: fn"+this.execMappingSignature)}else if(arguments.length>this.execMappingMaxArgs){throw new Error("[async] Too much arguments, in this instance, the function signature is: fn"+this.execMappingSignature)}if(this.execMappingAggregateArg){r++;t.aggregate=arguments[0]}if(this.execMappingMinInputs===this.execMappingMaxInputs){t.inputs=Array.prototype.slice.call(arguments,r,this.execMappingMaxInputs+r);for(n=0;n<this.execMappingCallbacks.length&&t.inputs.length+n<arguments.length;n++){t.callbacks[this.execMappingCallbacks[n]]=arguments[t.inputs.length+r+n]}}else{t.inputs=Array.prototype.slice.call(arguments,r,-this.execMappingCallbacks.length);for(n=0;n<this.execMappingCallbacks.length;n++){t.callbacks[this.execMappingCallbacks[n]]=arguments[t.inputs.length+r+n]}}return this.execInit(t)};s.Plan.prototype.execFinally=function e(t){return this.execInit({inputs:[],callbacks:{finally:t}})};s.Plan.prototype.execThenCatch=function e(t,r,n){return this.execInit({inputs:[],callbacks:{then:t,catch:r,finally:n}})};s.Plan.prototype.execThenElse=function e(t,r,n){return this.execInit({inputs:[],callbacks:{then:t,else:r,finally:n}})};s.Plan.prototype.execThenElseCatch=function e(t,r,n,i){return this.execInit({inputs:[],callbacks:{then:t,else:r,catch:n,finally:i}})};s.Plan.prototype.execArgs=function e(){return this.execInit({inputs:arguments,callbacks:{}})};s.Plan.prototype.execMapping=function e(t){if(this.locked){return this}t=i(null,{minInputs:0,maxInputs:0},t);var r,n,s=5;t.minInputs=parseInt(t.minInputs);t.maxInputs=parseInt(t.maxInputs);if(t.minInputs<t.maxInputs){this.execMappingMinInputs=t.minInputs;this.execMappingMaxInputs=t.maxInputs}else{this.execMappingMinInputs=t.maxInputs;this.execMappingMaxInputs=t.minInputs}this.execMappingCallbacks=Array.isArray(t.callbacks)?t.callbacks:[];this.execMappingInputsName=Array.isArray(t.inputsName)?t.inputsName:[];this.execMappingSignature="( ";if(this.execMappingMinInputs===this.execMappingMaxInputs){this.execMappingMinArgs=this.execMappingMinInputs;this.execMappingMaxArgs=this.execMappingMaxInputs+this.execMappingCallbacks.length;if(t.aggregateArg){this.execMappingAggregateArg=t.aggregateArg;this.execMappingMinArgs++;this.execMappingMaxArgs++;this.execMappingSignature+="aggregateValue"}for(r=0;r<this.execMappingMaxInputs;r++){if(r>0||t.aggregateArg){this.execMappingSignature+=", "}if(r>=s&&typeof this.execMappingInputsName[r]!=="string"){this.execMappingSignature+="... ";break}this.execMappingSignature+=typeof this.execMappingInputsName[r]==="string"?this.execMappingInputsName[r]:"arg#"+(r+1)}for(n=0;n<this.execMappingCallbacks.length;n++){if(r+n>0||t.aggregateArg){this.execMappingSignature+=", "}this.execMappingSignature+="["+this.execMappingCallbacks[n]+"Callback]"}}else{this.execMappingMinArgs=this.execMappingMinInputs+this.execMappingCallbacks.length;this.execMappingMaxArgs=this.execMappingMaxInputs+this.execMappingCallbacks.length;if(t.aggregateArg){this.execMappingAggregateArg=t.aggregateArg;this.execMappingMinArgs++;this.execMappingMaxArgs++;this.execMappingSignature+="aggregateValue"}for(r=0;r<this.execMappingMaxInputs;r++){if(r>0||t.aggregateArg){this.execMappingSignature+=", "}if(r<this.execMappingMinInputs){if(r>=s&&typeof this.execMappingInputsName[r]!=="string"){this.execMappingSignature+="... ";break}this.execMappingSignature+=typeof this.execMappingInputsName[r]==="string"?this.execMappingInputsName[r]:"arg#"+(r+1)}else{if(r>=s&&typeof this.execMappingInputsName[r]!=="string"){this.execMappingSignature+="[...] ";break}this.execMappingSignature+="["+(typeof this.execMappingInputsName[r]==="string"?this.execMappingInputsName[r]:"arg#"+(r+1))+"]"}}for(n=0;n<this.execMappingCallbacks.length;n++){if(r+n>0||t.aggregateArg){this.execMappingSignature+=", "}this.execMappingSignature+=this.execMappingCallbacks[n]+"Callback"}}this.execMappingSignature+=" )";return this};s.Plan.prototype.execKV=function e(t){if(t.inputs===undefined){t.inputs=[]}else if(!Array.isArray(t.inputs)){t.inputs=[t.inputs]}if(t.callbacks===undefined||typeof t.callbacks!=="object"){t.callbacks={}}if(t.then){t.callbacks.then=t.then}if(t.else){t.callbacks.else=t.else}if(t.catch){t.callbacks.catch=t.catch}if(t.finally){t.callbacks.finally=t.finally}return this.execInit(t)};s.Plan.prototype.execLoop=function e(t){return this.execInit({},t)};s.Plan.prototype.execJob=function e(t,r,n,o){var a=this,l,u=t.jobsKeys[n];var c=Object.create(s.JobContext.prototype,{execContext:{value:t,enumerable:true},indexOfKey:{value:n,enumerable:true},tryIndex:{value:o,enumerable:true},aborted:{value:false,writable:true,enumerable:true},abortedLoop:{value:false,writable:true,enumerable:true}});Object.defineProperty(c,"callback",{value:this.execCallback.bind(this,c),enumerable:true});Object.defineProperty(c.callback,"jobContext",{value:c,enumerable:true});t.jobsStatus[u].status="pending";t.jobsStatus[u].tried++;if(typeof this.jobsUsing==="function"){if(this.usingIsIterator){if(this.transmitAggregate){if(this.jobsUsing.length<=3){this.jobsUsing.call(c,t.aggregate,r,c.callback)}else if(this.jobsUsing.length<=4){this.jobsUsing.call(c,t.aggregate,r,Array.isArray(t.jobsData)?n:u,c.callback)}else{this.jobsUsing.call(c,t.aggregate,r,Array.isArray(t.jobsData)?n:u,t.jobsData,c.callback)}}else{if(this.jobsUsing.length<=2){this.jobsUsing.call(c,r,c.callback)}else if(this.jobsUsing.length<=3){this.jobsUsing.call(c,r,Array.isArray(t.jobsData)?n:u,c.callback)}else{this.jobsUsing.call(c,r,Array.isArray(t.jobsData)?n:u,t.jobsData,c.callback)}}}else if(Array.isArray(r)){l=r.slice();if(this.transmitAggregate){l.unshift(t.aggregate)}l.push(c.callback);this.jobsUsing.apply(c,l)}else{this.jobsUsing.call(c,r,c.callback)}}else if(typeof r==="function"){if(this.waterfallMode&&n>0){l=t.results[t.jobsKeys[n-1]].slice(this.waterfallTransmitError?0:1);l.push(c.callback);r.apply(c,l)}else if(Array.isArray(this.jobsUsing)||this.execMappingMaxInputs){if(Array.isArray(this.jobsUsing)){l=i(null,[],this.jobsUsing,t.execInputs)}else{l=i(null,[],t.execInputs)}l.push(c.callback);r.apply(c,l)}else{r.call(c,c.callback)}}else if(Array.isArray(r)&&typeof r[0]==="function"){l=r.slice(1);l.push(c.callback);r[0].apply(c,l)}else if(typeof r==="object"&&r instanceof s.Plan){r.exec(c.callback)}else{this.execCallback.call(this,c);return this}if(t.jobsTimeoutTimers[u]!==undefined){clearTimeout(t.jobsTimeoutTimers[u]);t.jobsTimeoutTimers[u]=undefined}if(t.retriesTimers[u]!==undefined){clearTimeout(t.retriesTimers[u]);t.retriesTimers[u]=undefined}if(typeof this.jobsTimeout==="number"&&this.jobsTimeout!==Infinity){t.jobsTimeoutTimers[u]=setTimeout(function(){t.jobsTimeoutTimers[u]=undefined;t.jobsStatus[u].status="timeout";c.emit("timeout");a.execCallback.call(a,c,new s.AsyncError("jobTimeout"))},this.jobsTimeout)}return this};s.Plan.prototype.execAction=function e(t,r,n){if(typeof r==="function"){r.apply(t,n)}else if(typeof r==="object"&&r instanceof s.Plan){r.exec()}};s.JobContext=function e(){throw new Error("[async] Cannot create an async JobContext object directly")};s.JobContext.prototype=Object.create(n.prototype);s.JobContext.prototype.constructor=s.JobContext;s.JobContext.prototype.abort=function e(){this.aborted=true;this.callback.apply(undefined,arguments)};s.JobContext.prototype.abortLoop=function e(){this.aborted=true;this.abortedLoop=true;this.callback.apply(undefined,arguments)};s.ExecContext=function e(){throw new Error("[async] Cannot create an async ExecContext object directly")};s.ExecContext.prototype=Object.create(n.prototype);s.ExecContext.prototype.constructor=s.ExecContext;s.ExecContext.prototype.getJobsStatus=function e(){var t,r,n=Array.isArray(this.jobsData)?[]:{};for(t=0;t<this.jobsKeys.length;t++){r=this.jobsKeys[t];n[r]=i(null,{job:this.jobsData[r],result:this.results[r]},this.jobsStatus[r])}return n};function a(e,t){var r,n,o=Array.isArray(this.jobsData);if(t&&t.whileIterator===-1){n=t;n.whileIterator=0}else{n=Object.create(s.ExecContext.prototype,{plan:{value:this},aggregate:{value:"aggregate"in e?e.aggregate:this.defaultAggregate,writable:true,enumerable:true},results:{value:o?[]:{},writable:true,enumerable:true},result:{value:undefined,writable:true,enumerable:true},jobsTimeoutTimers:{value:o?[]:{},writable:true},jobsStatus:{value:o?[]:{},writable:true,enumerable:true},retriesTimers:{value:o?[]:{},writable:true},retriesCounter:{value:o?[]:{},writable:true,enumerable:true},tryUserResponseCounter:{value:o?[]:{},writable:true,enumerable:true},tryResponseCounter:{value:o?[]:{},writable:true,enumerable:true},iterator:{value:0,writable:true,enumerable:true},pending:{value:0,writable:true,enumerable:true},resolved:{value:0,writable:true,enumerable:true},ok:{value:0,writable:true,enumerable:true},failed:{value:0,writable:true,enumerable:true},status:{value:undefined,writable:true,enumerable:true},error:{value:undefined,writable:true,enumerable:true},statusTriggerJobsKey:{value:undefined,writable:true,enumerable:true},whileStatus:{value:undefined,writable:true},whileChecked:{value:false,writable:true}});if(!t){Object.defineProperties(n,{root:{value:n,enumerable:true},jobsData:{value:o?this.jobsData.slice(0):i(null,{},this.jobsData),enumerable:true},jobsKeys:{value:this.jobsKeys.slice(0),enumerable:true},execInputs:{value:e.inputs,enumerable:true},execCallbacks:{value:e.callbacks},whileIterator:{value:0,enumerable:true,writable:true}})}else{Object.defineProperties(n,{root:{value:t.root,enumerable:true},jobsData:{value:t.jobsData,enumerable:true},jobsKeys:{value:t.jobsKeys,enumerable:true},execInputs:{value:t.execInputs,enumerable:true},execCallbacks:{value:t.execCallbacks},whileIterator:{value:t.whileIterator+1,enumerable:true,writable:true}})}Object.defineProperties(n,{waiting:{value:n.jobsKeys.length,writable:true,enumerable:true}});for(r=0;r<n.jobsKeys.length;r++){n.jobsStatus[n.jobsKeys[r]]={status:"waiting",errors:[],tried:0}}n.setNice(this.asyncEventNice);if(t===undefined){n.root.on("resolved",this.execFinal.bind(this,n));if(typeof this.whileAction==="function"){n.root.on("while",this.whileAction.bind(this));n.root.on("nextLoop",this.execLoop.bind(this))}else{this.whileAction=undefined;n.whileStatus=false}n.root.on("next",this.execNext.bind(this));if(this.whileAction&&this.whileActionBefore){n.whileIterator=-1;n.root.emit("while",n.error,n.results,this.execLoopCallback.bind(this,n),null);return this}}}if(n.jobsKeys.length<=0){n.root.emit("resolved",n.error,n.results);n.root.emit("progress",{resolved:n.resolved,ok:n.ok,failed:n.failed,pending:n.pending,waiting:n.waiting,loop:n.whileIterator},n.error,n.results);n.root.emit("finish",n.error,n.results);return n.root}n.root.emit("next",n);return n.root}function l(e){var t,r,n=e.jobsKeys.length,i,s;i=e.iterator;for(;e.iterator<n&&e.pending<this.parallelLimit;e.iterator++){e.pending++;e.waiting--;t=e.iterator;r=e.jobsKeys[t];e.retriesCounter[r]=0;e.tryResponseCounter[r]=[];e.tryResponseCounter[r][0]=0;e.tryUserResponseCounter[r]=[];e.tryUserResponseCounter[r][0]=0;e.results[r]=undefined;s=e.iterator}for(t=i;t<=s;t++){this.execJob(e,e.jobsData[e.jobsKeys[t]],t,0)}}function u(e,t){var r=e.execContext,n=e.aborted,i=e.abortedLoop,o=e.indexOfKey,a=e.tryIndex;var l=this,u,c,f=r.jobsKeys.length,p=r.jobsKeys[o];var h=false,d=false,v=false,y=false;r.tryResponseCounter[p][a]++;if(!(t instanceof s.AsyncError)){r.tryUserResponseCounter[p][a]++}if(r.jobsTimeoutTimers[p]!==undefined){clearTimeout(r.jobsTimeoutTimers[p]);r.jobsTimeoutTimers[p]=undefined}if(r.retriesTimers[p]!==undefined){clearTimeout(r.retriesTimers[p]);r.retriesTimers[p]=undefined}if(r.tryUserResponseCounter[p][a]>1){r.jobsStatus[p].errors.push(new Error("This job has called its completion callback "+r.tryUserResponseCounter[p][a]+" times"));return}if(!n&&r.results[p]!==undefined){return}if(!n&&t&&this.maxRetry>r.retriesCounter[p]&&r.tryResponseCounter[p][a]<=1){r.jobsStatus[p].errors.push(t);u=this.retryTimeout*Math.pow(this.retryMultiply,r.retriesCounter[p]);if(u>this.retryMaxTimeout){u=this.retryMaxTimeout}r.retriesCounter[p]++;c=r.retriesCounter[p];r.retriesTimers[p]=setTimeout(function(){r.retriesTimers[p]=undefined;r.tryResponseCounter[p][c]=0;r.tryUserResponseCounter[p][c]=0;l.execJob(r,r.jobsData[p],o,c)},u);return}if(!n&&t&&a<r.retriesCounter[p]){return}r.resolved++;r.pending--;r.aggregate=arguments[2];if(n){r.failed++;r.jobsStatus[p].status="aborted"}else if(t){r.failed++;r.jobsStatus[p].errors.push(t);if(t instanceof s.AsyncError&&t.message==="jobTimeout"){r.jobsStatus[p].status="timeout"}else{r.jobsStatus[p].status="failed"}}else{r.ok++;r.jobsStatus[p].status="ok"}if(this.returnMapping1to1){r.results[p]=arguments[2]}else{r.results[p]=Array.prototype.slice.call(arguments,1)}if(r.status===undefined){if(this.raceMode&&!t){r.status="ok";r.statusTriggerJobsKey=p;if(this.whileAction&&!i){y=true}else{d=true}}else if(!this.raceMode&&t&&this.errorsAreFatal){r.status="fail";r.error=t;r.statusTriggerJobsKey=p;if(this.whileAction&&!i){y=true}else{d=true}}else if(n){r.status="aborted";r.statusTriggerJobsKey=p;if(this.whileAction&&!i){y=true}else{d=true}}}if(r.resolved>=f){if(r.status===undefined){if(this.raceMode){r.status="fail"}else{r.status="ok"}r.statusTriggerJobsKey=p;if(this.whileAction){y=true}else{d=v=true}}else{if(!this.whileAction||r.whileChecked&&r.whileStatus!==true){v=true}}}else if(r.status===undefined){if(r.iterator<f){h=true}}else if(r.pending<=0){if(!this.whileAction||r.whileChecked&&r.whileStatus!==true){v=true}}if(d){r.root.emit("resolved",r.error,r.results)}if(h){r.root.emit("next",r)}if(y){r.root.emit("while",r.error,r.results,this.execLoopCallback.bind(this,r),null)}r.root.emit("progress",{resolved:r.resolved,ok:r.ok,failed:r.failed,pending:r.pending,waiting:r.waiting,loop:r.whileIterator},r.error,r.results);if(v){r.root.emit("finish",r.error,r.results)}}function c(e){var t,r;var n=false,i=false,s=false;if(arguments.length<=1){t=undefined;r=false}else if(arguments[1]instanceof Error){e.error=arguments[1];t=arguments[1];r=false}else if(arguments.length<=2){t=arguments[1];r=t?true:false}else{t=arguments[2];r=t?true:false}if(r){e.whileStatus=true;n=true}else{e.whileStatus=false;i=true;if(e.pending<=0){s=true}}if(i){e.root.emit("resolved",e.error,e.results)}if(n){e.root.emit("nextLoop",e)}if(s){e.root.emit("finish",e.error,e.results)}e.whileChecked=true}function f(e,t,r){var n;if(t){if(this.returnAggregate){n=[t,e.aggregate]}else if(this.returnLastJobOnly){n=r[e.statusTriggerJobsKey]}else{n=[t,r]}if(this.catchAction){this.execAction(e,this.catchAction,n)}if(t&&e.execCallbacks.catch){this.execAction(e,e.execCallbacks.catch,n)}}else{if(this.returnAggregate){n=[e.aggregate]}else if(this.returnLastJobOnly){n=r[e.statusTriggerJobsKey].slice(1)}else{n=[r]}if(this.thenAction){this.execAction(e,this.thenAction,n)}if(e.execCallbacks.then){this.execAction(e,e.execCallbacks.then,n)}}if(this.returnAggregate){n=[t,e.aggregate]}else if(this.returnLastJobOnly){n=r[e.statusTriggerJobsKey]}else{n=[t,r]}if(this.finallyAction){this.execAction(e,this.finallyAction,n)}if(e.execCallbacks.finally){this.execAction(e,e.execCallbacks.finally,n)}}function p(e){var t=e.execContext,r=e.indexOfKey,n=e.tryIndex;var i=this,o,a,l,u,c=t.jobsKeys.length,f=t.jobsKeys[r];var p=false,h=false,d=false;if(arguments.length<=1){t.result=undefined;o=false}else if(arguments[1]instanceof Error){t.error=u=arguments[1];t.result=arguments[1];o=false}else if(arguments.length<=2){t.result=arguments[1];o=t.result?true:false}else{t.result=arguments[2];o=t.result?true:false}t.tryResponseCounter[f][n]++;if(!(u instanceof s.AsyncError)){t.tryUserResponseCounter[f][n]++}if(t.jobsTimeoutTimers[f]!==undefined){clearTimeout(t.jobsTimeoutTimers[f]);t.jobsTimeoutTimers[f]=undefined}if(t.retriesTimers[f]!==undefined){clearTimeout(t.retriesTimers[f]);t.retriesTimers[f]=undefined}if(t.results[f]!==undefined){return}if(t.tryUserResponseCounter[f][n]>1){return}if(u&&this.maxRetry>t.retriesCounter[f]&&t.tryResponseCounter[f][n]<=1){a=this.retryTimeout*Math.pow(this.retryMultiply,t.retriesCounter[f]);if(a>this.retryMaxTimeout){a=this.retryMaxTimeout}t.retriesCounter[f]++;l=t.retriesCounter[f];t.retriesTimers[f]=setTimeout(function(){t.retriesTimers[f]=undefined;t.tryResponseCounter[f][l]=0;t.tryUserResponseCounter[f][l]=0;i.execJob(t,t.jobsData[f],r,l)},a);return}if(u&&n<t.retriesCounter[f]){return}t.resolved++;t.pending--;if(u){t.failed++;if(u instanceof s.AsyncError&&u.message==="jobTimeout"){t.jobsStatus[f].status="timeout"}else{t.jobsStatus[f].status="failed"}}else{t.ok++;t.jobsStatus[f].status="ok"}if(this.castToBoolean&&(!(t.result instanceof Error)||!this.catchAction)){t.result=o}t.results[f]=t.result;if(o!==this.useLogicAnd&&t.status===undefined){t.status=!this.useLogicAnd;h=true}if(t.resolved>=c){if(t.status===undefined){t.status=this.useLogicAnd;h=true}d=true}else if(t.status===undefined){if(t.iterator<c){p=true}}else if(t.pending<=0){d=true}if(h){t.root.emit("resolved",t.result)}if(p){t.root.emit("next",t)}t.root.emit("progress",{reso