<commit_before>function getTargetCoords(sourceCoords, direction) {
  var cx = sourceCoords.x,
      cy = sourceCoords.y;

  var panTargets = {
    left:  { x: cx - 1, y: cy     },
    right: { x: cx + 1, y: cy     },
    up:    { x: cx,     y: cy - 1 },
    down:  { x: cx,     y: cy + 1 }
  };

  var target = panTargets[direction];

  return target;
}

function verifyCoordsExist(pages, target) {
  if (pages.some(p => p.coords.x === target.x && p.coords.y === target.y)) {
    return true;
  } else {
    return false;
  }
}

module.exports = {
  handleDirectionClick: function (event) {
    var target = getTargetCoords(this.state.zoomedPageCoords, event);

    if (verifyCoordsExist(this.state.pages, target)) {
      this.zoomToPage(target);
    }
  },
  componentDidUpdate: function () {
    // Check what directions have pages that exist and update the dpad UI accordingly
    if (this.state.pages.length) {
      this.refs.dpad.bulkSetVisibility({
        showUp: verifyCoordsExist(this.state.pages, getTargetCoords(this.state.zoomedPageCoords, 'up')),
        showDown: verifyCoordsExist(this.state.pages, getTargetCoords(this.state.zoomedPageCoords, 'down')),
        showLeft: verifyCoordsExist(this.state.pages, getTargetCoords(this.state.zoomedPageCoords, 'left')),<commit_msg>checking mode to ensure data exists<commit_after>function getTargetCoords(sourceCoords, direction) {
  var cx = sourceCoords.x,
      cy = sourceCoords.y;

  var panTargets = {
    left:  { x: cx - 1, y: cy     },
    right: { x: cx + 1, y: cy     },
    up:    { x: cx,     y: cy - 1 },
    down:  { x: cx,     y: cy + 1 }
  };

  var target = panTargets[direction];

  return target;
}

function verifyCoordsExist(pages, target) {
  if (pages.some(p => p.coords.x === target.x && p.coords.y === target.y)) {
    return true;
  } else {
    return false;
  }
}

module.exports = {
  handleDirectionClick: function (event) {
    var target = getTargetCoords(this.state.zoomedPageCoords, event);

    if (verifyCoordsExist(this.state.pages, target)) {
      this.zoomToPage(target);
    }
  },
  componentDidUpdate: function () {
    // Check what directions have pages that exist and update the dpad UI accordingly
    if (this.state.isPageZoomed && this.state.pages.length) {
      this.refs.dpad.bulkSetVisibility({
        showUp: verifyCoordsExist(this.state.pages, getTargetCoords(this.state.zoomedPageCoords, 'up')),
        showDown: verifyCoordsExist(this.state.pages, getTargetCoords(this.state.zoomedPageCoords, 'down')),
        showLeft: verifyCoordsExist(this.state.pages, getTargetCoords(this.state.zoomedPageCoords, 'left')),
{'fraction_non_alphanumeric': 0.1337894336754086, 'fraction_numerical': 0.003040668947168377, 'mean_word_length': 3.217948717948718, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1187432', 'n_tokens_mistral': 916, 'n_tokens_neox': 896, 'n_words': 195}