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