<commit_before>module Workers
  class Store
    include SideJob::Worker
    register('core', 'Workers::Store', {
        description: 'Store and retrieve data',
        icon: 'database',
        inports: [
            { name: 'store', type: 'all', description: 'Data to store' },
            { name: 'retrieve', type: 'bang', description: 'Sends stored data on every packet' },
        ],
        outports: [
            { name: 'data', type: 'all', description: 'Stored data' },
        ],
    })

    def perform
      # handle stores
      if input(:store).size > 0
        data = input(:store).drain.last
        set(data: data)
      else
        data = get(:data)
      end

      # handle retrieves
      input(:retrieve).drain.length.times do
        output(:data).write data<commit_msg>simplify store worker<commit_after>module Workers
  class Store
    include SideJob::Worker
    register('core', 'Workers::Store', {
        description: 'Store and retrieve data',
        icon: 'database',
        inports: [
            { name: 'store', type: 'all', description: 'Data to store' },
            { name: 'retrieve', type: 'bang', description: 'Sends stored data on every packet' },
        ],
        outports: [
            { name: 'data', type: 'all', description: 'Stored data' },
        ],
    })

    def perform
      # handle stores
      data = get_config(:store)

      # handle retrieves
      input(:retrieve).each do
        output(:data).write data
{'fraction_non_alphanumeric': 0.131704005431093, 'fraction_numerical': 0.0006788866259334691, 'mean_word_length': 2.142857142857143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '617762', 'n_tokens_mistral': 417, 'n_tokens_neox': 408, 'n_words': 120}