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

node:repl. nstd: works; Node test suite 62.9% passing. Browser: not tested; export coverage 100%; Node test suite 10.3% passing.

  • nstd: Gives the same output as Node.js in side-by-side tests: repl.
  • Browser: Loads with a minimal process object. 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, undefined the other.
  • ❔ undefined both ways.
  • ❌ Not exported at all.
  • – Not measured.
ExportNode.jsBrowser
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 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.
  • 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.