<commit_before>'use strict';

export default function createHandler() {
  const names = {};
  const coords = {};
  const data = {
    stops: {},
    linedirs: {
      M1A: 'M1 → Kabaty',
      M1B: 'M1 → Młociny',
      M2A: 'M2 → <NAME>',
      M2B: 'M2 → <NAME>',
      X0A: '666 → Plac Testerów'
    },
  };

  return {
    onGetSchedules: function(res) {
      data.linedirs = res.schedule.reduce(
        getDirections, data.linedirs);
    },
    onGetBusStopsGroups: function(res) {
      for (let stop of res) {
        const name = stop.cityCode === '--' ?
          stop.name : stop.name + ', ' + stop.cityName;
        Object.assign(names, {
          [stop.id.toString()]: name
        });
      }
    },
    onGetBusStops: function(res) {
      for (let id in res) {
        Object.assign(coords, {
          [id]: getCenterOfMass(res[id])
        });
      }
    },
    get data() {
      for (let id in names) {
        Object.assign(data.stops, {
          [names[id]]: coords[id]
        });
      }
      return data;
    }
  };
};

function getDirections(seq, cur) {
  return Object.assign(
    seq, ...cur.routes.map(
      route => getDirectionsForLine(cur.id, route)));
}

function getDirectionsForLine(id, route) {<commit_msg>simplify handler<commit_after>'use strict';

export default function createHandler() {
  const names = {};
  const coords = {};
  const data = {
    stops: {},
    linedirs: {
      M1A: 'M1 → Kabaty',
      M1B: 'M1 → Młociny',
      M2A: 'M2 → <NAME>',
      M2B: 'M2 → <NAME>',
      X0A: '666 → Plac Testerów'
    },
  };

  return {
    onGetBusStopsGroups: function(res) {
      for (let stop of res) {
        const name = stop.cityCode === '--' ?
          stop.name : stop.name + ', ' + stop.cityName;
        Object.assign(data.stops, {
          [stop.id.toString()]: {
            name: name
          }
        });
      }
    },
    onGetBusStops: function(res) {
      for (let id in res) {
        Object.assign(data.stops[id], getCenterOfMass(res[id]));
      }
    },
    onGetSchedules: function(res) {
      data.linedirs = res.schedule.reduce(
        getDirections, data.linedirs);
    },
    get data() {
      return data;
    }
  };
};

function getDirections(seq, cur) {
  return Object.assign(
    seq, ...cur.routes.map(
      route => getDirectionsForLine(cur.id, route)));
}

function getDirectionsForLine(id, route) {
{'fraction_non_alphanumeric': 0.15651085141903173, 'fraction_numerical': 0.01001669449081803, 'mean_word_length': 2.0341772151898736, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '1821790', 'n_tokens_mistral': 847, 'n_tokens_neox': 837, 'n_words': 179}