replServer.setupHistory(historyConfig, callback)
historyConfig<Object> | <string> 历史文件的路径 如果它是一个字符串,则表示历史文件的路径。如果它是一个对象,它可以具有以下属性:filePath<string> 历史文件的路径size<number> 保留的历史记录行的最大数量。要禁用历史记录,请将此值设置为0。只有当用户或内部output检查将terminal设置为true时,此选项才有意义,否则历史缓存机制根本不会初始化。默认值:30。removeHistoryDuplicates<boolean> 如果为true,当向历史记录列表添加新输入行时,如果该行与已有的旧行重复,则会从列表中移除旧行。默认值:false。onHistoryFileLoaded<Function> 在历史记录写入准备好或发生错误时被调用err<Error>repl<repl.REPLServer>
callback<Function> 在历史记录写入准备就绪或出现错误时调用(如果在historyConfig中作为onHistoryFileLoaded提供,则为可选)err<Error>repl<repl.REPLServer>
为 REPL 实例初始化历史记录日志文件。当执行 Node.js 可执行文件并使用命令行 REPL 时,会默认初始化历史文件。但是,当以编程方式创建 REPL 时,情况并非如此。在以编程方式使用 REPL 实例时,请使用此方法初始化历史记录日志文件。
【Initializes a history log file for the REPL instance. When executing the Node.js binary and using the command-line REPL, a history file is initialized by default. However, this is not the case when creating a REPL programmatically. Use this method to initialize a history log file when working with REPL instances programmatically.】