readline: expose stream API in cursorTo()

This commit adds an optional callback to cursorTo(), which is
passed to the stream's write() method. It also exposes the
return value of write().

PR-URL: https://github.com/nodejs/node/pull/28674
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
cjihrig authored and Michaël Zasso committed 2019-07-20 11:13:06 +02:00
1 parent 4a7e20ff81
commit caee9106ac
3 files changed
+36 -17

No files matched your search

+9 -1
View File
@@ -487,14 +487,22 @@ function completer(linePartial, callback) {
}
```
## readline.cursorTo(stream, x, y)
## readline.cursorTo(stream, x, y[, callback])
<!-- YAML
added: v0.7.7
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/28674
description: The stream's write() callback and return value are exposed.
-->
* `stream` {stream.Writable}
* `x` {number}
* `y` {number}
* `callback` {Function} Invoked once the operation completes.
* Returns: {boolean} `false` if `stream` wishes for the calling code to wait for
the `'drain'` event to be emitted before continuing to write additional data;
otherwise `true`.
The `readline.cursorTo()` method moves cursor to the specified position in a
given [TTY][] `stream`.