设计和特点


¥Design and features

node:repl 模块导出 repl.REPLServer 类。当运行时,repl.REPLServer 的实例将接受用户输入的单行,根据用户定义的评估函数评估它们,然后输出结果。输入和输出可能分别来自 stdinstdout,或者可能连接到任何 Node.js

¥The node:repl module exports the repl.REPLServer class. While running, instances of repl.REPLServer will accept individual lines of user input, evaluate those according to a user-defined evaluation function, then output the result. Input and output may be from stdin and stdout, respectively, or may be connected to any Node.js stream.

repl.REPLServer 实例支持输入自动补全、补全预览、极简 Emacs 风格行编辑、多行输入、ZSH 类 reverse-i-search、ZSH 类子串历史搜索、ANSI 风格输出、保存和恢复 当前 REPL 会话状态、错误恢复和可定制的评估功能。不支持 ANSI 风格和 Emacs 风格的行编辑的终端会自动回退到有限的功能集。

¥Instances of repl.REPLServer support automatic completion of inputs, completion preview, simplistic Emacs-style line editing, multi-line inputs, ZSH-like reverse-i-search, ZSH-like substring-based history search, ANSI-styled output, saving and restoring current REPL session state, error recovery, and customizable evaluation functions. Terminals that do not support ANSI styles and Emacs-style line editing automatically fall back to a limited feature set.