How can I do something while a promise is pending as a function of it’s pending state?

For example, here’s some pseudocode of the kind of logic I want:

//Assume some promise exists.

while (promise is not resolved) {
      do something;

};

Been reading any doc on promises but I can’t seem to find an answer to my question.