如何从 Node.js 的用户输入中删除新行?
编码:
var net = require("net");
var clientData = null;
var server = net.createServer(function(client) {
client.on("connect", function() {
client.write("Enter something: ");
});
client.on("data", function(data) {
var clientData = data;
if (clientData != null) {
client.write("You entered " + "'" + clientData + "'" + ". Some more text.");
}
});
});
server.listen(4444);
假设我在控制台中输入“Test”,然后返回以下内容:
You entered 'Test
'. Some more text.
我希望这样的输出出现在单行中。我怎样才能做到这一点?