【发布时间】:2014-05-21 05:23:02
【问题描述】:
process.stdout.clearLine() 删除最后一行。如何删除 stdout 中的所有行?
var out = process.stdout;
out.write("1\n"); // prints `1` and new line
out.write("2"); // prints `2`
setTimeout(function () {
process.stdout.clearLine(); // clears the latest line (`2`)
out.cursorTo(0); // moves the cursor at the beginning of line
out.write("3"); // prints `3`
out.write("\n4"); // prints new line and `4`
console.log();
}, 1000);
输出是:
1
3
4
我想从stdout 中删除所有行而不是最新行,所以输出将是:
3
4
【问题讨论】: