summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/readline.js20
1 files changed, 10 insertions, 10 deletions
diff --git a/lib/readline.js b/lib/readline.js
index 2190c620bd..77b9dbc6c8 100644
--- a/lib/readline.js
+++ b/lib/readline.js
@@ -1189,21 +1189,21 @@ function emitKeypressEvents(stream, iface) {
* moves the cursor to the x and y coordinate on the given stream
*/
-function cursorTo(stream, x, y) {
- if (stream === null || stream === undefined)
- return;
+function cursorTo(stream, x, y, callback) {
+ if (callback !== undefined && typeof callback !== 'function')
+ throw new ERR_INVALID_CALLBACK(callback);
- if (typeof x !== 'number' && typeof y !== 'number')
- return;
+ if (stream == null || (typeof x !== 'number' && typeof y !== 'number')) {
+ if (typeof callback === 'function')
+ process.nextTick(callback);
+ return true;
+ }
if (typeof x !== 'number')
throw new ERR_INVALID_CURSOR_POS();
- if (typeof y !== 'number') {
- stream.write(CSI`${x + 1}G`);
- } else {
- stream.write(CSI`${y + 1};${x + 1}H`);
- }
+ const data = typeof y !== 'number' ? CSI`${x + 1}G` : CSI`${y + 1};${x + 1}H`;
+ return stream.write(data, callback);
}
/**