util: support inspecting Map, Set, and Promise by monsanto · Pull Request #1471 · nodejs/node

@bnoordhuis Thank you for your comments.

runInDebugContext isn't cheap

I've hoisted it to the top of the file for simplicity; however if this is too expensive or otherwise unsatisfactory I can create it on demand and cache.

only way to crack open a promise

If we could have compiler intrinsics enabled for the lib/internals folder, the Promise internals are at the properties %CreateGlobalPrivateOwnSymbol("Promise#status") and ...("Promise#value"). I don't know if this is more or less desirable than using runInDebugContext. My guess is less, but perhaps this functionality would be useful for other things in the future..

Mirrors being cached

you are correct, I should have noticed this. They are now created as "transient" so they will not be cached.

creating so many mirrors

I've guarded the mirror creation with an instanceof, so the common case should not be penalized. The code still calls inspectPromise twice if it is indeed a native promise, but I can't eliminate this without a more involved refactor (or creating a closure, which seems just as bad as creating an extra mirror). I have tried to keep my changes as minimal as possible as this is my first io.js PR.