<commit_before>class Monarch.Util.Node
  constructor: ->
    @clear()

  clear: ->
    @subscriptions = new JS.Set()

  publish: ->
    @publishArgs(arguments)

  publishArgs: (args) ->
    @subscriptions.forEach (subscription) ->
      subscription.publish(args)

  subscribe: (callback, context) ->
    subscription = new Monarch.Util.Subscription(callback, context, this)
    @subscriptions.add(subscription)
    subscription

  unsubscribe: (subscription) ->
    @subscriptions.remove(subscription)
    @emptyNode?.publish() if @size() == 0

  onEmpty: (callback, context) ->
    @emptyNode ?= new Monarch.Util.Node()
    @emptyNode.subscribe(callback, context)

  length: ->
    @subscriptions.length

  size: ->
    @subscriptions.size<commit_msg>Don't use JS.Set in subscription node<commit_after>class Monarch.Util.Node
  constructor: ->
    @clear()

  clear: ->
    @subscriptions = []

  publish: ->
    @publishArgs(arguments)

  publishArgs: (args) ->
    for subscription in @subscriptions
      subscription.publish(args)

  subscribe: (callback, context) ->
    subscription = new Monarch.Util.Subscription(callback, context, this)
    @subscriptions.push(subscription)
    subscription

  unsubscribe: (subscription) ->
    index = @subscriptions.indexOf(subscription)
    @subscriptions.splice(index, 1) unless index == -1
    @emptyNode?.publish() if @size() == 0

  onEmpty: (callback, context) ->
    @emptyNode ?= new Monarch.Util.Node()
    @emptyNode.subscribe(callback, context)

  length: ->
    @subscriptions.length

  size: ->
    @subscriptions.length
{'fraction_non_alphanumeric': 0.13345983554712207, 'fraction_numerical': 0.002530044275774826, 'mean_word_length': 3.52, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 22, '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': '5620960', 'n_tokens_mistral': 480, 'n_tokens_neox': 472, 'n_words': 98}