| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e51f924 commit e474c67
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -487,7 +487,7 @@ function completer(linePartial, callback) { | |||
| 487 | 487 | } | |
| 488 | 488 | ``` | |
| 489 | 489 | ||
| 490 | - ## readline.cursorTo(stream, x, y[, callback]) | ||
| 490 | + ## readline.cursorTo(stream, x[, y][, callback]) | ||
| 491 | 491 | <!-- YAML | |
| 492 | 492 | added: v0.7.7 | |
| 493 | 493 | changes: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -145,7 +145,7 @@ added: v0.7.7 | |||
| 145 | 145 | A `number` specifying the number of columns the TTY currently has. This property | |
| 146 | 146 | is updated whenever the `'resize'` event is emitted. | |
| 147 | 147 | ||
| 148 | - ### writeStream.cursorTo(x, y[, callback]) | ||
| 148 | + ### writeStream.cursorTo(x[, y][, callback]) | ||
| 149 | 149 | <!-- YAML | |
| 150 | 150 | added: v0.7.7 | |
| 151 | 151 | changes: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1193,6 +1193,11 @@ function cursorTo(stream, x, y, callback) { | |||
| 1193 | 1193 | if (callback !== undefined && typeof callback !== 'function') | |
| 1194 | 1194 | throw new ERR_INVALID_CALLBACK(callback); | |
| 1195 | 1195 | ||
| 1196 | + if (typeof y === 'function') { | ||
| 1197 | + callback = y; | ||
| 1198 | + y = undefined; | ||
| 1199 | + } | ||
| 1200 | + | ||
| 1196 | 1201 | if (stream == null || (typeof x !== 'number' && typeof y !== 'number')) { | |
| 1197 | 1202 | if (typeof callback === 'function') | |
| 1198 | 1203 | process.nextTick(callback); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -133,6 +133,10 @@ writable.data = ''; | |||
| 133 | 133 | assert.strictEqual(readline.cursorTo(writable, 1, 'a'), true); | |
| 134 | 134 | assert.strictEqual(writable.data, '\x1b[2G'); | |
| 135 | 135 | ||
| 136 | + writable.data = ''; | ||
| 137 | + assert.strictEqual(readline.cursorTo(writable, 1), true); | ||
| 138 | + assert.strictEqual(writable.data, '\x1b[2G'); | ||
| 139 | + | ||
| 136 | 140 | writable.data = ''; | |
| 137 | 141 | assert.strictEqual(readline.cursorTo(writable, 1, 2), true); | |
| 138 | 142 | assert.strictEqual(writable.data, '\x1b[3;2H'); | |
@@ -141,6 +145,10 @@ writable.data = ''; | |||
| 141 | 145 | assert.strictEqual(readline.cursorTo(writable, 1, 2, common.mustCall()), true); | |
| 142 | 146 | assert.strictEqual(writable.data, '\x1b[3;2H'); | |
| 143 | 147 | ||
| 148 | + writable.data = ''; | ||
| 149 | + assert.strictEqual(readline.cursorTo(writable, 1, common.mustCall()), true); | ||
| 150 | + assert.strictEqual(writable.data, '\x1b[2G'); | ||
| 151 | + | ||
| 144 | 152 | // Verify that cursorTo() throws on invalid callback. | |
| 145 | 153 | assert.throws(() => { | |
| 146 | 154 | readline.cursorTo(writable, 1, 1, null); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments