0

I need to write a function that returns a boolean based on whether a promise is fulfilled or not at the moment that function is invoked. Obviously, I cannot await the promise (otherwise, it will always be fulfilled), I need to know immediately upon calling the function whether or not the promise is fulfilled (either resolved or rejected).

I've been poking around SO and the internet for a solution for this, but other than util.inspect from Node.JS that I cannot use, I haven't seen a reliable solution for this.

Any assistance would be highly appreciated!

Jonathan Perry
  • 2,953
  • 2
  • 44
  • 51
  • Why do you think you need this? Maybe a cleaner design exists where you don't. – Thomas Mar 03 '21 at 08:17
  • @Thomas I converted an existing code into a Promise. I cannot change the entire API now and I have to convert a function that returned a boolean up until now to deal with a promise instead of a state like before :/ – Jonathan Perry Mar 03 '21 at 08:21
  • That's what I thought. Async code tends to be contagious, so changing entire swathes of code at once is to be expected, sadly. – Thomas Mar 03 '21 at 08:22

0 Answers0