<commit_before>'use strict';

const Cache = require('json-fetch-cache');

const parse = (data) => {
  const parsed = {
    kuva: [],
    arbitration: {},
  };

  const now = new Date();

  data.forEach((mission) => {
    const p = {
      activation: new Date(mission.start),
      expiry: new Date(mission.end),
      solnode: mission.solnode,
      node: `${mission.solnodedata.tile} (${mission.solnodedata.planet})`,
      ...mission.solnodedata,
    };
    p.activation.setMinutes(p.activation.getMinutes() + 5.1);
    if (p.activation < now && now < p.expiry) {
      if (mission.missiontype === 'EliteAlertMission') {
        parsed.arbitration = p;
      }
      if (mission.missiontype.startsWith('KuvaMission')) {
        parsed.kuva.push(p);
      }
    }
  });

  return parsed;
};

const defaultCache = new Cache('https://10o.io/kuvalog.json', 300000, { useEmitter: false, delayStart: true, maxRetry: 5 });

/**
 * External mission data retrieved from https://10o.io/kuvalog.json
 * @typedef {ExternalMission}
 * @property {Date} activation start time
 * @property {Date} expiry end time
 * @property {string} solnode plain text solnode identifier
 * @property {string} node formatted node name with planet
 * @property {string} name similar to node, but different formatting
 * @property {string} tile tile on a planet
 * @property {string} planet planet the mission is on
 * @property {string} enemy Enemy on tile
 * @property {string} type Mission type of node
 * @property {string} node_type node type identifier
 * @property {boolean} archwing whether or not the tile requires archwing
 * @property {boolean} sharkwing whether or not the tile requires
 *    sumbersible archwing
 */

/**
 * Stores and parses kuva data from https://10o.io/kuvalog.json
 * @property {ExternalMission[]} kuva currently active kuva missions
 * @property {ExternalMission} arbitration current arbitration
 */
class Kuva {
  constructor(cache = defaultCache) {
    this.cache = cache;
    this.cache.getData()
      .then((data) => {
        const parsed = parse(data);
        this.kuva = parsed.kuva;
        this.arbitration = parsed.arbitration;
      });
  }
}
<commit_msg>fix(kuva): don't let emitter start by default, or create an extra by default<commit_after>'use strict';

const Cache = require('json-fetch-cache');

const parse = (data) => {
  const parsed = {
    kuva: [],
    arbitration: {},
  };

  const now = new Date();

  data.forEach((mission) => {
    const p = {
      activation: new Date(mission.start),
      expiry: new Date(mission.end),
      solnode: mission.solnode,
      node: `${mission.solnodedata.tile} (${mission.solnodedata.planet})`,
      ...mission.solnodedata,
    };
    p.activation.setMinutes(p.activation.getMinutes() + 5.1);
    if (p.activation < now && now < p.expiry) {
      if (mission.missiontype === 'EliteAlertMission') {
        parsed.arbitration = p;
      }
      if (mission.missiontype.startsWith('KuvaMission')) {
        parsed.kuva.push(p);
      }
    }
  });

  return parsed;
};

/**
 * External mission data retrieved from https://10o.io/kuvalog.json
 * @typedef {ExternalMission}
 * @property {Date} activation start time
 * @property {Date} expiry end time
 * @property {string} solnode plain text solnode identifier
 * @property {string} node formatted node name with planet
 * @property {string} name similar to node, but different formatting
 * @property {string} tile tile on a planet
 * @property {string} planet planet the mission is on
 * @property {string} enemy Enemy on tile
 * @property {string} type Mission type of node
 * @property {string} node_type node type identifier
 * @property {boolean} archwing whether or not the tile requires archwing
 * @property {boolean} sharkwing whether or not the tile requires
 *    sumbersible archwing
 */

/**
 * Stores and parses kuva data from https://10o.io/kuvalog.json
 * @property {ExternalMission[]} kuva currently active kuva missions
 * @property {ExternalMission} arbitration current arbitration
 */
class Kuva {
  constructor(cache) {
    this.cache = cache || new Cache('https://10o.io/kuvalog.json', 300000, { useEmitter: false, delayStart: true, maxRetry: 5 });
    this.cache.getData()
      .then((data) => {
        const parsed = parse(data);
        this.kuva = parsed.kuva;
        this.arbitration = parsed.arbitration;
      });
  }
}

{'fraction_non_alphanumeric': 0.12940100594421583, 'fraction_numerical': 0.006858710562414266, 'mean_word_length': 3.3489065606361827, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 6, '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': '1939698', 'n_tokens_mistral': 1374, 'n_tokens_neox': 1313, 'n_words': 389}