repl: support .help expression for introspection#64479
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #64479 +/- ##
==========================================
- Coverage 90.24% 90.23% -0.01%
==========================================
Files 741 739 -2
Lines 241665 241931 +266
Branches 45543 45608 +65
==========================================
+ Hits 218092 218313 +221
- Misses 15105 15127 +22
- Partials 8468 8491 +23
🚀 New features to boost your workflow:
|
bbcbd69 to
8d989cb
Compare
|
|
8d989cb to
49c4da6
Compare
|
hmm, so it would be like |
|
having any repl command that doesn't start with |
|
nods, but we do have just the |
Extend the `.help` REPL command to accept an optional expression. When one is given, it is evaluated in the REPL context and introspection information about the resulting value is printed: type, function signature, properties, methods, and prototype chain. Without an argument, `.help` prints the command listing as before. An earlier revision injected a global `help()` function into the REPL context instead; review feedback was that REPL functionality should live behind dot-commands rather than pollute the context. Refs: nodejs#51763 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
49c4da6 to
a9e0938
Compare
.help expression for introspection
|
Reworked as suggested: the global
Nothing is added to the REPL context anymore, so there's no pollution in //cc @avivkeller @ljharb && @nodejs/repl |
Description
Extend the
.helpREPL command to accept an optional expression, providing interactive introspection without adding anything to the REPL context.Without an argument,
.helpprints the command listing exactly as before. With an argument, the expression is evaluated in the REPL context and introspection info about the resulting value is printed.Usage
Implementation Details
.help expressionevaluates the expression via the REPL's owneval(so custom evaluators, context vars, etc. all work) and prints type, function kind (Function/AsyncFunction/GeneratorFunction/Class), signature, own properties categorized into Methods/Accessors/Properties, and the prototype chainutil.styleTextfor colorized output (respectsNO_COLOR)help()approach was dropped in favor of extending the existing dot-commandRefs: #51763