rl.write(data[, key])


rl.write() 方法将把 data 或由 key 标识的按键序列写入 output。只有当 output文字电话 文本终端时,才支持 key 参数。有关按键组合的列表,请参见 TTY 键绑定

【The rl.write() method will write either data or a key sequence identified by key to the output. The key argument is supported only if output is a TTY text terminal. See TTY keybindings for a list of key combinations.】

如果指定了 keydata 将被忽略。

【If key is specified, data is ignored.】

当被调用时,rl.write() 将会恢复已暂停的 input 流。

【When called, rl.write() will resume the input stream if it has been paused.】

如果 readline.Interface 是在将 output 设置为 nullundefined 的情况下创建的,则 datakey 不会被写入。

【If the readline.Interface was created with output set to null or undefined the data and key are not written.】

rl.write('Delete this!');
// Simulate Ctrl+U to delete the line written previously
rl.write(null, { ctrl: true, name: 'u' }); 

rl.write() 方法会将数据写入 readline Interfaceinput就好像是用户提供的一样

【The rl.write() method will write the data to the readline Interface's input as if it were provided by the user.】