code: function doResolve(fn, onFulfilled, onRejected) {
  		var done = false;
  		try {
  			fn(function (value) {
  				if (done) return;
  				done = true;
  				onFulfilled(value);
  			}, function (reason) {
  				if (done) return;
  				done = true;
  				onRejected(reason);
  			})
  		} catch (ex) {
  			if (done) return;
  			done = true;
  			onRejected(ex);
  		}
  	}
docs: Take a potentially misbehaving resolver function and make sure
  onFulfilled and onRejected are only called once.
  
  Makes no guarantees about asynchrony.