作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
当使用 readline 接口(interface)时,从 stdin 到 stdout 的所有内容都会打印两次:
var rl = require('readline');
var i = rl.createInterface(process.stdin, process.stdout);
当我运行这段代码时,我在终端中输入的所有内容都会被复制。输入“hello world”会产生:
hheelloo wwoorrlldd
我想这样做是有道理的,因为 readline 模块旨在将输入通过管道传递到输出。但它不也意味着用于创建命令行界面吗?我对我应该如何使用它感到困惑。帮忙?
最佳答案
尝试使用 terminal: false
:
var readline = require("readline");
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
terminal: false
});
关于node.js - createInterface 在终端中打印两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24661774/
我正在尝试在 jasmine 上编写测试以检查是否调用了 readline.createInterface(),但我不断收到一条错误消息:TypeError: readline.createInter
当使用 readline 接口(interface)时,从 stdin 到 stdout 的所有内容都会打印两次: var rl = require('readline'); var i = rl.c
尝试使用 .csv 文件中的值构建请求正文,但我的点数组未更新。我已经为 on() 函数内部和末尾的点数组完成了 console.log() ,并且值按预期存在。但我在 on() 之外console.
我正在尝试创建一个电子应用程序。在 main.ts 中,我构造了一个我认为相当简单的类(如下),但构造函数不会运行。对 readline.createInterface(inputStream) 的调
我是一名优秀的程序员,十分优秀!