readline: y in cursorTo is optional by Flarna · Pull Request #29128 · nodejs/node · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/api/readline.md
2 changes: 1 addition & 1 deletion doc/api/tty.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ added: v0.7.7
A `number` specifying the number of columns the TTY currently has. This property
is updated whenever the `'resize'` event is emitted.

### writeStream.cursorTo(x, y[, callback])
### writeStream.cursorTo(x[, y][, callback])
<!-- YAML
added: v0.7.7
changes:
Expand Down
5 changes: 5 additions & 0 deletions lib/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,11 @@ function cursorTo(stream, x, y, callback) {
if (callback !== undefined && typeof callback !== 'function')
throw new ERR_INVALID_CALLBACK(callback);

if (typeof y === 'function') {
callback = y;
y = undefined;
}

if (stream == null || (typeof x !== 'number' && typeof y !== 'number')) {
if (typeof callback === 'function')
process.nextTick(callback);
Expand Down
8 changes: 8 additions & 0 deletions test/parallel/test-readline-csi.js