<commit_before>makeExtender = (top) ->
  (name, values...) ->
    ancestors = name.split(/[./\\]/g)
    leaf = ancestors.pop()
    parent = resolveAncestors(ancestors, top)

    verifyDistinctness(name, values[0], parent[leaf])

    if isExtensible(parent[leaf], values)
      _(parent[leaf]).extend(values...)
    else if arguments.length > 1
      parent[leaf] = values[0]; #what to do here?
    parent[leaf]

isExtensible = (existing, values) ->
  existing? && !_(values).some(_.isFunction) && !_(existing).isFunction()

resolveAncestors = (ancestors, top) ->
  _(ancestors).reduce (ancestor, child) ->
    ancestor[child] ||= {}
  , top

verifyDistinctness = (name, value, existing) ->
  if _(existing).isFunction() && value? && existing != value
    throw "Cannot override \"#{name}\", because it is already defined as a function."<commit_msg>Handle multiple args when attempting to extend a function<commit_after>makeExtender = (top) ->
  (name, values...) ->
    ancestors = name.split(/[./\\]/g)
    leaf = ancestors.pop()
    parent = resolveAncestors(ancestors, top)

    verifyDistinctness(name, values, parent[leaf])

    if isExtensible(parent[leaf], values)
      _(parent[leaf]).extend(values...)
    else if arguments.length > 1
      parent[leaf] = values.pop();
    parent[leaf]

isExtensible = (existing, values) ->
  existing? && !_(values).any(_.isFunction) && !_(existing).isFunction()

resolveAncestors = (ancestors, top) ->
  _(ancestors).reduce (ancestor, child) ->
    ancestor[child] ||= {}
  , top

verifyDistinctness = (name, values, existing) ->
  if _(existing).isFunction() && _(values).any((v) -> existing != v)
    throw "Cannot override \"#{name}\", because it is already defined as a function."
{'fraction_non_alphanumeric': 0.17167630057803468, 'fraction_numerical': 0.0023121387283236996, 'mean_word_length': 3.7295081967213113, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, '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': '5354316', 'n_tokens_mistral': 551, 'n_tokens_neox': 550, 'n_words': 133}