I'm writing the equivalent of Node's inspect function. I need it to properly inspect promises. E.g.: > inspect(Promise.resolve(5)) "Promise { 5 }" and > inspect(new Promise(resolve => undefined)) "Promise { <pending> }". How do I do it? I absolutely cannot call `.then`.
-
Show this thread
-
Seems like the best answer is: 1. Write your own promise library (or fully wrap an existing one). 2. Stuff it into the global namespace, smashing window.Promise. 3. Redefine window.fetch to use your promise library. 4. Repeat (3) for all other built-in functions.
1 reply 0 retweets 9 likesShow this thread -
Which... to state it gently... is not a great solution.
1 reply 0 retweets 13 likesShow this thread -
You also have to do all of that before loading any libraries that might use promises. And if they import a promise library to use (like Bluebird), I guess you have to intercept that import somehow and substitute your thing?
1 reply 0 retweets 5 likesShow this thread -
For now I've completely punted and special cased this: if an Execute Program code example returns a promise, then we'll resolve it and show what's inside. Not the ideal solution but it's probably enough for this course and the rule is easy to state to the user.
2 replies 0 retweets 4 likesShow this thread
I think this is the extent of what you can reasonably do short of what you described above
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.