MCPcopy Index your code
hub / github.com/nodejs/node / clearLine

Method clearLine

lib/internal/readline/promises.js:93–103  ·  view source on GitHub ↗

* Clears the current line the cursor is on. * @param {-1|0|1} dir Direction to clear: * -1 for left of the cursor * +1 for right of the cursor * 0 for the entire line * @returns {Readline} this

(dir)

Source from the content-addressed store, hash-verified

91 * @returns {Readline} this
92 */
93 clearLine(dir) {
94 validateInteger(dir, 'dir', -1, 1);
95
96 const data =
97 dir < 0 ? kClearToLineBeginning :
98 dir > 0 ? kClearToLineEnd :
99 kClearLine;
100 if (this.#autoCommit) process.nextTick(() => this.#stream.write(data));
101 else ArrayPrototypePush(this.#todo, data);
102 return this;
103 }
104
105 /**
106 * Clears the screen from the current position of the cursor down.

Callers 7

constructorMethod · 0.45
tty.jsFile · 0.45
updateProgressMethod · 0.45
#clearSpinnerMethod · 0.45

Calls 1

writeMethod · 0.45

Tested by

no test coverage detected