<commit_before>import _ from './utils';

export default {
  all: (obj = {}) => {
    return obj.transitions || [];
  },

  getByRel: (transitions = [], rel) => {
    let link;

    // Returns the embedded transition first if it finds it
    for (const transition of transitions) {
      if (_.includes(transition.rels, rel)) {
        if (transition.tag === 'embed') return transition;
        if (transition.tag === 'link' && !link) link = transition;
      }
    }

    return link;
  },

  filterByRel: (transitions = [], rel) => {
    return transitions.filter(transition => {
      return _.includes(transition.rels, rel);
    });
  },

  filterByTag: (transitions = [], tag) => {
    return transitions.filter(transition => {
      return transition.tag === tag;
    });
  },
};<commit_msg>Simplify looping through transactions<commit_after>import _ from './utils';

export default {
  all: (obj = {}) => {
    return obj.transitions || [];
  },

  getByRel: (transitions = [], rel) => {
    let link;

    // Returns the embedded transition first if it finds it
    for (let i = 0; i < transitions.length; i++) {
      let transition = transitions[i];
      if (_.includes(transition.rels, rel)) {
        if (transition.tag === 'embed') return transition;
        if (transition.tag === 'link' && !link) link = transition;
      }
    }

    // If a link was not found above, this will be undefined
    return link;
  },

  filterByRel: (transitions = [], rel) => {
    return transitions.filter(transition => {
      return _.includes(transition.rels, rel);
    });
  },

  filterByTag: (transitions = [], tag) => {
    return transitions.filter(transition => {
      return transition.tag === tag;
    });
  },
};
{'fraction_non_alphanumeric': 0.15902495647127105, 'fraction_numerical': 0.0005803830528148578, 'mean_word_length': 2.6759061833688698, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 15, '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': '3555788', 'n_tokens_mistral': 512, 'n_tokens_neox': 496, 'n_words': 139}