rl.write(data[, key])
rl.write()
方法会将 data
或由 key
标识的键序列写入 output
。
仅当 output
是 TTY 文本终端时才支持 key
参数。
有关组合键的列表,请参阅 TTY 快捷键。
如果指定了 key
,则忽略 data
。
当调用时,如果 rl.write()
流已暂停,则 rl.write()
将恢复 input
流。
如果 readline.Interface
是在 output
设置为 null
或 undefined
的情况下创建的,则不会写入 data
和 key
。
rl.write('Delete this!');
//
rl.write(null, { ctrl: true, name: 'u' });
rl.write()
方法将数据写入 readline
Interface
的 input
,就好像它是由用户提供的一样。
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.
If key
is specified, data
is ignored.
When called, rl.write()
will resume the input
stream if it has been
paused.
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' });
The rl.write()
method will write the data to the readline
Interface
's
input
as if it were provided by the user.