// when when somebody has screwed with setTimeout but no I.E. maddness
returncachedSetTimeout(fun,0);
}catch(e){
try{
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
returncachedSetTimeout.call(null,fun,0);
}catch(e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
returncachedSetTimeout.call(this,fun,0);
}
}
}
functionrunClearTimeout(marker){
if(cachedClearTimeout===clearTimeout){
//normal enviroments in sane situations
returnclearTimeout(marker);
}
// if clearTimeout wasn't available but was latter defined
// when when somebody has screwed with setTimeout but no I.E. maddness
returncachedClearTimeout(marker);
}catch(e){
try{
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
returncachedClearTimeout.call(null,marker);
}catch(e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
returncachedClearTimeout.call(this,marker);
}
}
}
varqueue=[];
vardraining=false;
varcurrentQueue;
varqueueIndex=-1;
functioncleanUpNextTick(){
if(!draining||!currentQueue){
return;
}
draining=false;
if(currentQueue.length){
queue=currentQueue.concat(queue);
}else{
queueIndex=-1;
}
if(queue.length){
drainQueue();
}
}
functiondrainQueue(){
if(draining){
return;
}
vartimeout=runTimeout(cleanUpNextTick);
draining=true;
varlen=queue.length;
while(len){
currentQueue=queue;
queue=[];
while(++queueIndex<len){
if(currentQueue){
currentQueue[queueIndex].run();
}
}
queueIndex=-1;
len=queue.length;
}
currentQueue=null;
draining=false;
runClearTimeout(timeout);
}
process.nextTick=function(fun){
varargs=newArray(arguments.length-1);
if(arguments.length>1){
for(vari=1;i<arguments.length;i++){
args[i-1]=arguments[i];
}
}
queue.push(newItem(fun,args));
if(queue.length===1&&!draining){
runTimeout(drainQueue);
}
};
// v8 likes predictible objects
functionItem(fun,array){
this.fun=fun;
this.array=array;
}
Item.prototype.run=function(){
this.fun.apply(null,this.array);
};
process.title='browser';
process.browser=true;
process.env={};
process.argv=[];
process.version='';// empty string to avoid regexp issues