code: function completed(promise, value) {
          var targetState;
          if (value && typeof value === "object" && typeof value.then === "function") {
              targetState = state_waiting;
          } else {
              targetState = state_success_notify;
          }
          promise._value = value;
          promise._setState(targetState);
      }
docs: Implementations of shared state machine code.