How to use the clearScreenDown function from readline

Find comprehensive JavaScript readline.clearScreenDown code examples handpicked from public code repositorys.

241
242
243
244
245
246
247
248
249
250
// source: https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-shared-utils/lib/logger.js
if (process.stdout.isTTY) {
  const blank = '\n'.repeat(process.stdout.rows);
  console.log(blank);
  readline.cursorTo(process.stdout, 0, 0);
  readline.clearScreenDown(process.stdout);
  if (msg) {
    console.log(msg);
  }
}
fork icon56
star icon71
watch icon16

32
33
34
35
36
37
38
39
40
41
42
43
assert.deepStrictEqual(writable.data, CSI.kClearScreenDown);
assert.strictEqual(readline.clearScreenDown(writable, common.mustCall()), true);


// Verify that clearScreenDown() throws on invalid callback.
assert.throws(() => {
  readline.clearScreenDown(writable, null);
}, /ERR_INVALID_CALLBACK/);


// Verify that clearScreenDown() does not throw on null or undefined stream.
assert.strictEqual(readline.clearScreenDown(null, common.mustCall((err) => {
fork icon0
star icon0
watch icon0

+ 5 other calls in file

18
19
20
21
22
23
24
25
26
27
let currentKeyIndex = 0;
let currentDependencyIndex = 0;

// const printDependencies = () => {
//   readline.moveCursor(process.stdout, 0, -1000); // 将光标移动到屏幕最上方
//   readline.clearScreenDown(process.stdout); // 清除屏幕
//   const key = keys[currentKeyIndex];
//   process.stdout.write(key.toUpperCase() + ":\n");
//   const depKeys = Object.keys(dependencies[key]);
//   depKeys.forEach((depKey, index) => {
fork icon0
star icon0
watch icon0

+ 3 other calls in file

429
430
431
432
433
434
435
436
437
438
  if (this._stdout.isTTY && process.env.TERM !== 'dumb') {
    // The require is here intentionally to avoid readline being
    // required too early when console is first loaded.
    const { cursorTo, clearScreenDown } = require('readline');
    cursorTo(this._stdout, 0, 0);
    clearScreenDown(this._stdout);
  }
},

// Defined by: https://console.spec.whatwg.org/#count
fork icon0
star icon0
watch icon0

77
78
79
80
81
82
83
84
85
86
  if (!this.capturing && this.enabled && process.stdout.isTTY) {
    // Fill screen with blank lines. Then move to 0 (beginning of visible part) and clear it
    const blank = '\n'.repeat(process.stdout.rows)
    console.log(blank)
    readline.cursorTo(process.stdout, 0, 0)
    readline.clearScreenDown(process.stdout)
  }
}

captureLogs (fun) {
fork icon0
star icon0
watch icon0