node:repl
#Import
import repl from "nstdlib/node/repl";Note
The API is available, but not everything works. repl.start({ input, output }) works over any pair of streams, which is what test/runtime/repl.test.ts drives: evaluation, multiline continuation, top-level await, completion and the dot commands. A prompt on a terminal additionally needs a host to build process.stdin and to back the TTY handle in internalBinding('tty_wrap'). native/ does both, and a bare nstd on a terminal is this REPL. breakEvalOnSigint stays refused by name everywhere: it is a SigintWatchdog thread calling Isolate::TerminateExecution, so a running expression cannot be interrupted. Ctrl-C at the prompt is unaffected.
#Support
- nstd: Gives the same output as Node.js in side-by-side tests: repl.
- Browser: Loads with a minimal
processobject. 9 of Node's 9 exports are available. No behavior check covers it yet.
#Exports (9)
Every name Node.js exports from this module, and what you get when you read it, as a named import or as a property of the default import:
- ✅ A value, both ways. An export that throws an error naming the missing feature also counts.
- ⚠️ A value one way,
undefinedthe other. - ❔
undefinedboth ways. - ❌ Not exported at all.
- – Not measured.
| Export | Node.js | Browser |
|---|---|---|
REPLServer | ✅ | ✅ |
REPL_MODE_SLOPPY | ✅ | ✅ |
REPL_MODE_STRICT | ✅ | ✅ |
Recoverable | ✅ | ✅ |
_builtinLibs | ✅ | ✅ |
builtinModules | ✅ | ✅ |
isValidSyntax | ✅ | ✅ |
repl | ❌ | ❌ |
start | ✅ | ✅ |
writer | ✅ | ✅ |
#Diagnostics
nstdlib running inside Node.js. This isn't an environment it's meant for, so it isn't shown above, but it tells a library problem from an environment one:
coverage: 9/9 of the host's export names answer inside host node. API only.repl.start({ input, output })works over any pair of streams, which is whattest/runtime/repl.test.tsdrives: evaluation, multiline continuation, top-levelawait, completion and the dot commands. A prompt on a terminal additionally needs a host to buildprocess.stdinand to back theTTYhandle ininternalBinding('tty_wrap').native/does both, and a barenstdon a terminal is this REPL.breakEvalOnSigintstays refused by name everywhere: it is aSigintWatchdogthread callingIsolate::TerminateExecution, so a running expression cannot be interrupted. Ctrl-C at the prompt is unaffected.smoke: Imports in a clean child process.vitest: Test/runtime/repl.test.ts: 17/17 assertions pass.node-suite: 56/106 of Node's own eligible tests pass with ./dist inside host node. A failure there and in the page is the library's, one only in the page is the engine's.