Skip to content

Commit

Permalink
update main script
Browse files Browse the repository at this point in the history
  • Loading branch information
IbrahimTanyalcin committed Oct 25, 2017
1 parent b346aab commit bb58c88
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions taskq.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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());
Expand All @@ -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();
Expand Down

0 comments on commit bb58c88

Please sign in to comment.