diff --git a/taskq.js b/taskq.js index 3330653..4dc2c92 100644 --- a/taskq.js +++ b/taskq.js @@ -8,22 +8,22 @@ tasks = []; exports = {}; return this; - } + }; this.export = function(f,name){ - var name = name || "default"; + name = name || "default"; exports[name] = f; return this; - } + }; this.push = function(f){ tasks.push(f); return this; - } + }; this.perform = function(){ var base = Math.max.apply(null,tasks.map(function(d,i){return (d._taskqWaitFor || []).length})) + 1,//About max 2^16 tasks keywordStart = ["start","init","begin","loadstart","loadStart"],//regex could do also - executed first keywordEnd = ["end","defer","finish","loadend","loadEnd"];//executed last tasks.map(function(d,i){ - return [d,d._taskqId,d._taskqWaitFor] + return [d,d._taskqId,d._taskqWaitFor]; }).sort(function(a,b){ var aId = a[1], bId = b[1], @@ -41,7 +41,7 @@ return aL.some(function(d,i){return d === bId})*base+aL.length - bL.some(function(d,i){return d === aId})*base - bL.length; } }).map(function(d,i){ - return d[0] + return d[0]; }).forEach(function(d,i){ if(typeof d === "function") { var captured = (/function\s*\w*\s*\(((?:\s*\w+\s*\,?\s*)+)\)\s*\{/).exec(d.toString()); @@ -54,13 +54,13 @@ .map(function(d,i){return exports[d]}) : void(0) - ) + ); } else { console.log("not a function ref"); } },this); return this; - } + }; }; window.addEventListener("load",function(){ taskq.perform().flush();