<commit_before>memos = 0

Trix.Helpers =
  defer: (fn) ->
    setTimeout fn, 1

  memoize: (fn) ->
    memo = memos++
    ->
      @memos ?= {}
      @memos[memo] ?= fn.apply(this, arguments)

  capitalize: (string) ->
    string.charAt(0).toUpperCase() + string.substring(1)

  decapitalize: (string) ->
    string.charAt(0).toLowerCase() + string.substring(1)

  forwardMethods: ({fromConstructor, toConstructor, viaProperty} = {}) ->
    methods = toConstructor.prototype
    destination = fromConstructor.prototype

    for own name, value of methods when name isnt "constructor" and typeof value is "function"
      do (name, value) =>
        destination[name] = -> value.apply(@[viaProperty], arguments) if @[viaProperty]?<commit_msg>Forward all methods except constructor, toString, valueOf<commit_after>memos = 0

Trix.Helpers =
  defer: (fn) ->
    setTimeout fn, 1

  memoize: (fn) ->
    memo = memos++
    ->
      @memos ?= {}
      @memos[memo] ?= fn.apply(this, arguments)

  capitalize: (string) ->
    string.charAt(0).toUpperCase() + string.substring(1)

  decapitalize: (string) ->
    string.charAt(0).toLowerCase() + string.substring(1)

  forwardMethods: ({fromConstructor, toConstructor, viaProperty} = {}) ->
    methods = toConstructor.prototype
    destination = fromConstructor.prototype
    reservedNames = ["constructor", "toString", "valueOf"]

    for name, value of methods when name not in reservedNames and typeof value is "function"
      do (name, value) =>
        destination[name] = -> value.apply(@[viaProperty], arguments) if @[viaProperty]?
{'fraction_non_alphanumeric': 0.14339861023373343, 'fraction_numerical': 0.007580543272267846, 'mean_word_length': 3.525714285714286, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '4533764', 'n_tokens_mistral': 494, 'n_tokens_neox': 490, 'n_words': 119}