<commit_before>import { isArrayLike, isUndefined } from './checkTypes';

export function iterate(object, mapFn) {
  const array = isArrayLike(object);

  let iterated = 0;

  for (const key in object) {
    if (object.hasOwnProperty(key)) {
      if (array && iterated++ === object.length) {
        break;
      }

      const value = mapFn(object[key], array ? Number(key) : key, object);

      if (!isUndefined(value)) {
        return value;
      }
    }
  }
}<commit_msg>helpers.iterate: change break conditions.<commit_after>import { isArrayLike, isUndefined } from './checkTypes';

export function iterate(object, mapFn) {
  const array = isArrayLike(object);

  let iterated = 0;

  for (const key in object) {
    if (object.hasOwnProperty(key)) {
      if (array && iterated++ >= object.length) {
        break;
      }

      const value = mapFn(object[key], array ? Number(key) : key, object);

      if (!isUndefined(value)) {
        return value;
      }
    }
  }
}
{'fraction_non_alphanumeric': 0.1363173957273652, 'fraction_numerical': 0.002034587995930824, 'mean_word_length': 2.7846153846153845, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '5683250', 'n_tokens_mistral': 316, 'n_tokens_neox': 304, 'n_words': 79}