设计和特点


【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 的反向 i 搜索、类似 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.】