q.js : Is it possible to know if a promise has resolved/rejected or not

promise, q

Solution

I got the answer by looking into q.js source.

deferred.promise.inspect().state

This will return the state of the promise.

returns "fulfilled" if it was resolved or fulfilled
returns "rejected" if it was rejected
returns "pending" if it hasn't been resolved or rejected

Problem

In my scenario I return a promise when I'm making a request. In the end I resolve/reject the deferred obj. I want to reuse the promise if it hasn't been resolved/rejected. Any info would be useful.

Original source