<commit_before>import jsonPath from 'JSONPath';

export default function (blob, config) {
  const json = blob.toJSON();

  Object.entries(config).map(([path, linker]) => {
    const jsonResult = jsonPath({ json, path, resultType: 'all' });
    const result = jsonResult[0];

    if (!result) {
      return undefined;
    }

    if (typeof result.value === 'string') {
      return linker(blob, result.parentProperty, result.value);
    }

    for (const node of jsonResult) {
      for (const [key, value] of Object.entries(node.value)) {
        linker(blob, key, value);
      }
    }
  });
}<commit_msg>Simplify `processJSON()` array handling<commit_after>import jsonPath from 'JSONPath';

export default function (blob, config) {
  const json = blob.toJSON();

  Object.entries(config).map(([path, linker]) => {
    jsonPath({ json, path, resultType: 'all' }).forEach((result) => {
      if (typeof result.value === 'string') {
        return linker(blob, result.parentProperty, result.value);
      }

      for (const [key, value] of Object.entries(result.value)) {
        linker(blob, key, value);
      }
    });
  });
}
{'fraction_non_alphanumeric': 0.15752212389380532, 'fraction_numerical': 0.0008849557522123894, 'mean_word_length': 3.188888888888889, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '909766', 'n_tokens_mistral': 354, 'n_tokens_neox': 339, 'n_words': 90}