Node.js: printing to console without a trailing newline?

后端 未结 8 2200
-上瘾入骨i
-上瘾入骨i 2020-11-28 00:27

Is there a method for printing to the console without a trailing newline? The console object documentation doesn\'t say anything regarding that:

8条回答
  •  無奈伤痛
    2020-11-28 00:35

    In Windows console (Linux, too), you should replace '\r' with its equivalent code \033[0G:

    process.stdout.write('ok\033[0G');
    

    This uses a VT220 terminal escape sequence to send the cursor to the first column.

提交回复
热议问题