<commit_before>export const getDisplayName = Component => Component.displayName || Component.name || 'Component'

export const splitPath = (path, at = '.') => path.split(at)

export const applyPathValue = (json, path, value) => {
  let current = json

  if (value === undefined) return current

  let key = path

  if (path.includes('.')) {
    const keys = splitPath(path)

    for (key of keys.slice(0, keys.length - 1)) {
      if (!current[key]) current[key] = {}
      current = current[key]
    }

    key = keys[keys.length - 1]
  }

  if (key.endsWith('[]')) {
    key = key.slice(0, key.length - 2)

    if (!current[key]) {
      current[key] = [value]
    } else {
      current[key].push(value)
    }
  } else {
    current[key] = value
  }
  return json
}<commit_msg>Quick update to applyPathValue<commit_after>export const getDisplayName = Component => Component.displayName || Component.name || 'Component'

export const splitPath = (path, at = '.') => path.split(at)

export const applyPathValue = (json, path, value) => {
  if (value === undefined) return json

  let current = json
  let key = path

  if (path.includes('.')) {
    const keys = splitPath(path)

    for (key of keys.slice(0, keys.length - 1)) {
      if (!current[key]) current[key] = {}
      current = current[key]
    }

    key = keys[keys.length - 1]
  }

  if (key.endsWith('[]')) {
    key = key.slice(0, key.length - 2)
    if (!current[key]) current[key] = [value]
    current[key].push(value)
  } else {
    current[key] = value
  }

  return json
}
{'fraction_non_alphanumeric': 0.16062176165803108, 'fraction_numerical': 0.006476683937823834, 'mean_word_length': 2.9213197969543145, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7606943', 'n_tokens_mistral': 524, 'n_tokens_neox': 505, 'n_words': 134}