<commit_before>require 'opal'
require 'opal/compiler'
require 'object_extensions'

class OpalIrb
  def irb_vars
    %x|irbVars = [];
       for(variable in Opal.irb_vars) {
         if(Opal.irb_vars.hasOwnProperty(variable)) {
            irbVars.push([variable, Opal.irb_vars[variable]])
         }
       };
       return irbVars;|
  end

  def opal_classes
    classes = []
    $opal_js_object = Native(`Opal`)    # have to make this global right now coz not seen in the each closure w/current opal
    $opal_js_object.each {|k|
      attr = $opal_js_object[k]
      classes << attr if attr.is_a?(Class)
    }
    classes.uniq                # coz some Opal classes are the same, i.e. module == class, base, Kernel = Object
  end

  attr_reader :parser
  def initialize
    @parser = Opal::Compiler.new
  end

  def parse(cmd)
    @parser.compile cmd, :irb => true
  end

end<commit_msg>sort the classes by name<commit_after>require 'opal'
require 'opal/compiler'
require 'object_extensions'

class OpalIrb
  def irb_vars
    %x|irbVars = [];
       for(variable in Opal.irb_vars) {
         if(Opal.irb_vars.hasOwnProperty(variable)) {
            irbVars.push([variable, Opal.irb_vars[variable]])
         }
       };
       return irbVars;|
  end

  def opal_classes
    classes = []
    $opal_js_object = Native(`Opal`)    # have to make this global right now coz not seen in the each closure w/current opal
    $opal_js_object.each {|k|
      attr = $opal_js_object[k]
      classes << attr if attr.is_a?(Class)
    }
    classes.uniq.sort_by &:name                # coz some Opal classes are the same, i.e. module == class, base, Kernel = Object
  end

  attr_reader :parser
  def initialize
    @parser = Opal::Compiler.new
  end

  def parse(cmd)
    @parser.compile cmd, :irb => true
  end

end
{'fraction_non_alphanumeric': 0.1035437430786268, 'fraction_numerical': 0.0, 'mean_word_length': 2.62124248496994, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '1019231', 'n_tokens_mistral': 626, 'n_tokens_neox': 617, 'n_words': 162}