rem: dojo.Deferred = function(/* optional */ canceller){ 
add: dojo.Deferred = function(/*Function?*/ canceller){ 
context: dojo.Deferred = function(/* optional */ canceller){	/*	NOTE: this namespace and documentation are imported wholesale 		from MochiKit	Encapsulates a sequence of callbacks in response to a value that	may not yet be available.  This is modeled after the Deferred class	from Twisted <http://twistedmatrix.com>.	Why do we want this?  JavaScript has no threads, and even if it did,	threads are hard.  Deferreds are a way of abstracting non-blocking	events, such as the final response to an XMLHttpRequest.	The sequence of callbacks is internally represented as a list	of 2-tuples containing the callback/errback pair.  For example,	the following call sequence::		var d = new Deferred();		d.addCallback(myCallback);		d.addErrback(myErrback);		d.addBoth(myBoth);		d.addCallbacks(myCallback, myErrback);	is translated into a Deferred with the following internal	representation::		[			[myCallback, null],			[null, myErrback],			[myBoth, myBoth],			[myCallback, myErrback]		]	The Deferred also keeps track of its current status (fired).	Its status may be one of three things:		-1: no value yet (initial condition)		0: success		1: error	A Deferred will be in the error state if one of the following	three conditions are met:		1. The result given to callback or errback is "instanceof" Error		2. The previous callback or errback raised an exception while		   executing		3. The previous callback or errback returned a value "instanceof"			Error	Otherwise, the Deferred will be in the success state.  The state of	the Deferred determines the next element in the callback sequence to	run.	When a callback or errback occurs with the example deferred chain,	something equivalent to the following will happen (imagine that	exceptions are caught and returned)::		// d.callback(result) or d.errback(result)		if(!(result instanceof Error)){			result = myCallback(result);		}		if(result instanceof Error){			result = myErrback(result);		}		result = myBoth(result);		if(result instanceof Error){			result = myErrback(result);		}else{			result = myCallback(result);		}	The result is then stored away in case another step is added to the	callback sequence.	Since the Deferred already has a value available,	any new callbacks added will be called immediately.	There are two other "advanced" details about this implementation that	are useful:	Callbacks are allowed to return Deferred instances themselves, so you	can build complicated sequences of events with ease.	The creator of the Deferred may specify a canceller.  The canceller	is a function that will be called if Deferred.cancel is called before	the Deferred fires.	 You can use this to implement clean aborting of	an XMLHttpRequest, etc.	 Note that cancel will fire the deferred with	a CancelledError (unless your canceller returns another kind of	error), so the errbacks should be prepared to handle that error for	cancellable Deferreds.	*/		this.chain = [];	this.id = this._nextId();	this.fired = -1;	this.paused = 0;	this.results = [null, null];	this.canceller = canceller;	this.silentlyCancelled = false;};
meta: 4707	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/4707/50c3492c4c3c825dbd3401e134a19ed46799c456/Deferred.js/buggy/www/resources/dojo-ajax/src/Deferred.js