<commit_before>'use strict';

const osData = require('./osData');
const tableData = require('./tabelData');
const settings = require('./settings');
const logUpdate = require('log-update');
const figLet = require('figlet');
const chalk = require('chalk');

class Outputter {

  constructor() {
    this.interval = null;
    this.newLine = '\n';
    this.headline = '   >>>   GUNBOT - MONITOR   <<<';
  }

  print() {
    this.collectOutputAndUpdateConsoleLog();
  }

  collectOutputAndUpdateConsoleLog() {
    Promise.all([osData.getMemoryGauge(), osData.getLoad(), tableData.getTable()])
      .then(values => logUpdate(this.buildOutput(...values)))
      .catch(error => logUpdate(this.buildOutput(undefined, undefined, undefined, error)));
  }

  buildOutput(memory, load, table, error) {
    let output = this.printHeadline();
    output += this.newLine;
    output += memory;
    output += this.newLine;
    output += load;
    output += this.newLine;
    output += this.newLine;
    output += table;
    output += this.newLine;
    output += this.newLine;
    output += chalk.italic('Use `CTRL+C` to exit.');
    output += this.newLine;

    if (error !== undefined) {
      output += error;
    }

    return output;
  }

  start() {
    this.print();

    this.interval = setInterval(() => {
      this.print();
    }, settings.outputIntervalDelay);
  }

  stop() {
    clearInterval(this.interval);
  }

  // ------

  printHeadline() {
    let newLine = this.newLine;
    let headline = this.headline;

    figLet.text(headline, {
      font: 'Standard'
    }, function (err, data) {
      if (err) {
        console.log(newLine + chalk.bold.yellow(headline));
        return;
      }
      console.log(newLine + chalk.bold.yellow(data));
    });
  }

}

module.exports = new Outputter();<commit_msg>Wait till the headline is printed and than run the interval.<commit_after>'use strict';

const osData = require('./osData');
const tableData = require('./tabelData');
const settings = require('./settings');
const logUpdate = require('log-update');
const figLet = require('figlet');
const chalk = require('chalk');

class Outputter {

  constructor() {
    this.interval = null;
    this.newLine = '\n';
    this.headline = '   >>>   GUNBOT - MONITOR   <<<';
  }

  print() {
    this.collectOutputAndUpdateConsoleLog();
  }

  collectOutputAndUpdateConsoleLog() {
    Promise.all([osData.getMemoryGauge(), osData.getLoad(), tableData.getTable()])
      .then(values => logUpdate(this.buildOutput(...values)))
      .catch(error => logUpdate(this.buildOutput(undefined, undefined, undefined, error)));
  }

  buildOutput(memory, load, table, error) {
    let output = this.newLine;
    output += memory;
    output += this.newLine;
    output += load;
    output += this.newLine;
    output += this.newLine;
    output += table;
    output += this.newLine;
    output += this.newLine;
    output += chalk.italic('Use `CTRL+C` to exit.');
    output += this.newLine;

    if (error !== undefined) {
      output += error;
    }

    return output;
  }

  start() {
    this.printHeadline()
      .then(() => {
        this.print();

        this.interval = setInterval(() => {
          this.print();
        }, settings.outputIntervalDelay);
      });
  }

  stop() {
    clearInterval(this.interval);
  }

  // ------

  printHeadline() {
    return new Promise(resolve => {
      let newLine = this.newLine;
      let headline = this.headline;

      figLet.text(headline, {
        font: 'Standard'
      }, function (err, data) {
        if (err) {
          console.log(newLine + chalk.bold.yellow(headline));
          resolve(true);
          return;
        }
        console.log(newLine + chalk.bold.yellow(data));
        resolve(true);
      });
    });
  }

}

module.exports = new Outputter();
{'fraction_non_alphanumeric': 0.1617724174095438, 'fraction_numerical': 0.0, 'mean_word_length': 2.707482993197279, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4592519', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1166, 'n_words': 240}