How to use readline - 10 common examples

To help you get started, we’ve selected a few readline examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googlemaps / transport-tracker / backend / generate_paths.js View on Github external
function logProgress(str) {
  // A little bit of readline magic to not fill the screen with progress messages.
  readline.clearLine(process.stdout, 0);
  readline.cursorTo(process.stdout, 0, null);
  process.stdout.write(str);
}
github superpowers / superpowers-core / server / commands / utils.ts View on Github external
function onProgress(value: number) {
  value = Math.round(value * 100);

  readline.clearLine(process.stdout, 0);
  readline.cursorTo(process.stdout, 0, 1);
  console.log(`${value}%`);
  if (process != null && process.send != null) process.send({ type: "progress", value });
}
github quantumsheep / warshield / src / UserInterface.js View on Github external
function clearScreen() {
  const blank = '\n'.repeat(process.stdout.rows);
  console.log(blank);
  readline.cursorTo(process.stdout, 0, 0);
  readline.clearScreenDown(process.stdout);
}
github gngeorgiev / JsShell / src / shell.js View on Github external
this.paths = this.settings.env.PATH.split(':');

            this.home = this.settings.env.HOME;
            this.cwd = this.home;
            this.completer = new Completer(this);
            this.executor = new Executor(this);

            const input = process.stdin;
            const output = process.stdout;
            const terminal = true;
            const completer = this.completer.complete.bind(this.completer);
            this.rl = readline.createInterface({input, output, terminal, completer});
            this.setPrompt();
            this._readHistory();

            readline.emitKeypressEvents(process.stdin, this.rl);
            if (process.stdin.isTTY) {
                process.stdin.setRawMode(true);
            }

            this._lineCallbacks = [];
            this._attachHandlers();
            this._fireInitialized();
        });
    }
github skyujilong / tinypng-webpack-plugin / src / uploader.js View on Github external
yield new Promise(function (resolve, reject) {
        let rl = readline.createInterface({
            input: fs.createReadStream(dictPath)
        });
        rl.on('line', function (line) {
            //给dict对象 添加属性与对应的值
            if (line && line.indexOf(splitCode) >= 0) {
                let list = line.split(splitCode);
                dict[list[0]] = list[1];
            }
        });
        rl.on('close', function () {
            resolve(dict);
        })
    });
}
github albertosantini / node-nanoirc / lib / nanoirc.js View on Github external
function printMessage({
        from = null,
        me = null,
        to = null,
        text = "",
        timestamp = new Date()
    } = {}) {
        const message = formatter(from, me, to, text, timestamp);

        readline.clearLine(process.stdout, 0);
        readline.cursorTo(process.stdout, 0);
        process.stdout.write(message);
        rl.prompt(true);
    }
github GoogleChrome / lighthouse / lighthouse-core / scripts / lantern / collect-traces.js View on Github external
progress(message) {
    this._currentProgressMessage = message;
    readline.clearLine(process.stdout, 0);
    readline.cursorTo(process.stdout, 0);
    if (message) process.stdout.write(`${this._nextLoadingChar()} ${message}`);
  }
github damonjs / damon / src / reporter.js View on Github external
function clear () {
    readline.clearLine(writeStream);
    readline.cursorTo(writeStream, 0);
}
github nicksellen / german / bin / german-quiz.js View on Github external
function ask(question, callback) {
  var rl = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
  });
  rl.question(question, function(answer) {
    rl.close();
    callback(answer);
  });
}
github teambit / bit / bin / bit-updates.js View on Github external
function _askUser(cb) {
  const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout });
  rl.question('\u001b[1;36mThere is a new version of Bit, would you like to update? [Y/n]: \u001b[0m', function (
    answer
  ) {
    cb(answer === 'y' || answer === 'Y');
    rl.close();
  });
}

readline

Simple streaming readline module.

BSD
Latest version published 8 years ago

Package Health Score

62 / 100
Full package analysis