future.js
function(value) {
		if (this.resolved) {
			throw new Error('Future resolved more than once');
		}
		this.value = value;
		this.resolved = true;

		var callbacks = this.callbacks;
		if (callbacks) {
			delete this.callbacks;
			for (var ii = 0; ii < callbacks.length; ++ii) {
				try {
					var ref = callbacks[ii];
					if (ref[1]) {
						ref[1](value);
					} else {
						ref[0](undefined, value);
					}
				} catch(ex) {
					// console.log('Resolve cb threw', String(ex.stack || ex.message || ex));
					process.nextTick(function() {
						throw(ex);
					});
				}
			}
		}
	}
function(value) {
		if (this.resolved) {
			throw new Error('Future resolved more than once');
		}
		this.value = value;
		this.resolved = true;

		var callbacks = this.callbacks;
		if (callbacks) {
			delete this.callbacks;
			for (var ii = 0; ii < callbacks.length; ++ii) {
				try {
					var ref = callbacks[ii];
					if (ref[1]) {
						ref[1](value);
					} else {
						ref[0](undefined, value);
					}
				} catch(ex) {
					// console.log('Resolve cb threw', String(ex.stack || ex.message || ex));
					process.nextTick(function() {
						throw(ex);
					});
				}
			}
		}
	}
function ( value ) { if ( this . resolved ) { throw new Error ( 'Future resolved more than once' ) ; } this . value = value ; this . resolved = true ; var callbacks = this . callbacks ; if ( callbacks ) { delete this . callbacks ; for ( var ii = 0 ; ii < callbacks . length ; ++ ii ) { try { var ref = callbacks [ ii ] ; if ( ref [ 1 ] ) { ref [ 1 ] ( value ) ; } else { ref [ 0 ] ( undefined , value ) ; } } catch ( ex ) { // console.log('Resolve cb threw', String(ex.stack || ex.message || ex)); process . nextTick ( function ( ) { throw ( ex ) ; } ) ; } } } }
Mark this future as returned. All pending callbacks will be invoked immediately.
Mark this future as returned . All pending callbacks will be invoked immediately .