<commit_before>KNOWN_KEYS = []
STACK = []

root = this

save_old = ->
  mix = {}
  mix[key] = root[key] for key in KNOWN_KEYS
  STACK.unshift mix

add_known_keys = (set) ->
  for key, value of set
    if $.inArray key, KNOWN_KEYS is -1
      KNOWN_KEYS.push key

apply = (set) ->
  root[key] = value for key, value of set

@set_mixins = (sets) -> apply set for set in sets

push = (set) ->
  add_known_keys set
  save_old()
  apply set

pop = -> apply STACK.shift()

@with_mixin = (sets, fun) ->
  if $.isArray sets
    push set for set in sets
  else
    push sets
  r = fun()
  if $.isArray sets
    pop() for set in sets
  else
    pop()
  r<commit_msg>Shortened with_mixin() to make debug stepping quicker.<commit_after>KNOWN_KEYS = []
STACK = []

root = this

save_old = ->
  mix = {}
  mix[key] = root[key] for key in KNOWN_KEYS
  STACK.unshift mix

add_known_keys = (set) ->
  for key, value of set
    if $.inArray key, KNOWN_KEYS is -1
      KNOWN_KEYS.push key

apply = (set) ->
  root[key] = value for key, value of set

@set_mixins = (sets) -> apply set for set in sets

push = (set) ->
  add_known_keys set
  save_old()
  apply set

push_set_or_sets = (sets) ->
  if $.isArray sets
    push set for set in sets
  else
    push sets

pop = -> apply STACK.shift()

pop_set_or_sets = (sets) ->
  if $.isArray sets
    pop() for set in sets
  else
    pop()

@with_mixin = (sets, fun) ->
  push_set_or_sets sets
  r = fun()
  pop_set_or_sets sets
  r
{'fraction_non_alphanumeric': 0.11720356408498972, 'fraction_numerical': 0.0013708019191226869, 'mean_word_length': 2.7055837563451774, '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': '723983', 'n_tokens_mistral': 565, 'n_tokens_neox': 567, 'n_words': 181}