<commit_before>module Modulr
  class Collector
    attr_reader :modules, :main
    
    def initialize(options = {})
      @root = options[:root]
      @lazy_eval = options[:lazy_eval]
      @modules = []
    end
    
    def parse_file(path)
      @src = File.read(path)
      @root ||= File.dirname(path)
      @main = JSModule.new(File.basename(path, '.js'), @root, path)
      modules << main
      collect_dependencies(main)
    end
    
    def to_js(buffer = '')
      buffer << File.read(PATH_TO_MODULR_JS)
      buffer << "\n(function(require, module) {"
      buffer << transport
      buffer << main.ensure
      buffer << "})(modulr.require, {});\n"
    end
    
    def transport
      pairs = modules.map do |m|
        if lazy_eval_module?(m)
          value = m.escaped_src<commit_msg>Set require.main to the topmost (unidentified) "module".<commit_after>module Modulr
  class Collector
    attr_reader :modules, :main
    
    def initialize(options = {})
      @root = options[:root]
      @lazy_eval = options[:lazy_eval]
      @modules = []
    end
    
    def parse_file(path)
      @src = File.read(path)
      @root ||= File.dirname(path)
      @main = JSModule.new(File.basename(path, '.js'), @root, path)
      modules << main
      collect_dependencies(main)
    end
    
    def to_js(buffer = '')
      buffer << File.read(PATH_TO_MODULR_JS)
      buffer << "\n(function(require, module) {"
      buffer << "\nrequire.main = module;"
      buffer << transport
      buffer << main.ensure
      buffer << "})(modulr.require, {});\n"
    end
    
    def transport
      pairs = modules.map do |m|
        if lazy_eval_module?(m)
          value = m.escaped_src
{'fraction_non_alphanumeric': 0.1338862559241706, 'fraction_numerical': 0.0, 'mean_word_length': 2.3379446640316206, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 3, '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': '1743981', 'n_tokens_mistral': 552, 'n_tokens_neox': 550, 'n_words': 118}