<commit_before># In-browser CoffeeScript REPL
# https://github.com/larryng/coffeescript-repl
# 
# written by <NAME>

require ['jquery', 'coffee-script', 'nodeutil'], ($, CoffeeScript, nodeutil) ->

  $ ->
    SAVED_CONSOLE_LOG = console.log
    DEFAULT_LAST_VARIABLE = '$_'
    
    $output    = $('#output')
    $input     = $('#input')
    $prompt    = $('#prompt')
    $inputdiv  = $('#inputdiv')
    $inputl    = $('#inputl')
    $inputr    = $('#inputr')
    $inputcopy = $('#inputcopy')
    
    class CoffeeREPL
      constructor: (@output, @input, @prompt, settings={}) ->
        @history = []
        @historyi = -1
        @saved = ''
        @multiline = false
        
        @settings =
          lastVariable: DEFAULT_LAST_VARIABLE
        
        for k, v of settings
          @settings[k] = v
      
      print: (args...) ->
        s = args.join(' ') or ' '
        @output[0].innerHTML += "<pre>#{s}</pre>"
        undefined
      
      grabInput: ->
        tmp = @input.val()
        $input.val ''
        tmp
      
      processSaved: () ->
        try
          compiled = CoffeeScript.compile @saved
          compiled = compiled[14...-17]
          value = eval.call window, compiled
          window[@settings.lastVariable] = value
          output = nodeutil.inspect value
        catch e
          if e.stack
            output = e.stack
            
            # FF doesn't have Error.toString() as the first line of Error.stack
            # while Chrome does.
            if output.split('\n')[0] isnt e.toString()
              ouput = "#{e.toString()}\n#{e.stack}"
          else
            output = e.toString()
        @saved = ''
        @print output
      
      setPrompt: () ->
        s = if @multiline then '------' else 'coffee'
        @prompt.html "#{s}&gt;&nbsp;"
      
      addToHistory: (s) ->
        @history.unshift s
        @historyi = -1
      
      addToSaved: (s) ->
        @saved += if s[...-1] is '\\' then s[0...-1] else s
        @saved += '\n'
        @addToHistory s
      
      handleKeypress: (e) ->
        switch e.which<commit_msg>use colored inspect output<commit_after># In-browser CoffeeScript REPL
# https://github.com/larryng/coffeescript-repl
# 
# written by <NAME>

require ['jquery', 'coffee-script', 'nodeutil'], ($, CoffeeScript, nodeutil) ->

  $ ->
    SAVED_CONSOLE_LOG = console.log
    DEFAULT_LAST_VARIABLE = '$_'
    
    $output    = $('#output')
    $input     = $('#input')
    $prompt    = $('#prompt')
    $inputdiv  = $('#inputdiv')
    $inputl    = $('#inputl')
    $inputr    = $('#inputr')
    $inputcopy = $('#inputcopy')
    
    class CoffeeREPL
      constructor: (@output, @input, @prompt, settings={}) ->
        @history = []
        @historyi = -1
        @saved = ''
        @multiline = false
        
        @settings =
          lastVariable: DEFAULT_LAST_VARIABLE
        
        for k, v of settings
          @settings[k] = v
      
      print: (args...) ->
        s = args.join(' ') or ' '
        @output[0].innerHTML += "<pre>#{s}</pre>"
        undefined
      
      grabInput: ->
        tmp = @input.val()
        $input.val ''
        tmp
      
      processSaved: () ->
        try
          compiled = CoffeeScript.compile @saved
          compiled = compiled[14...-17]
          value = eval.call window, compiled
          window[@settings.lastVariable] = value
          output = nodeutil.inspect value, undefined, undefined, true
        catch e
          if e.stack
            output = e.stack
            
            # FF doesn't have Error.toString() as the first line of Error.stack
            # while Chrome does.
            if output.split('\n')[0] isnt e.toString()
              ouput = "#{e.toString()}\n#{e.stack}"
          else
            output = e.toString()
        @saved = ''
        @print output
      
      setPrompt: () ->
        s = if @multiline then '------' else 'coffee'
        @prompt.html "#{s}&gt;&nbsp;"
      
      addToHistory: (s) ->
        @history.unshift s
        @historyi = -1
      
      addToSaved: (s) ->
        @saved += if s[...-1] is '\\' then s[0...-1] else s
        @saved += '\n'
        @addToHistory s
      
      handleKeypress: (e) ->
        switch e.which
{'fraction_non_alphanumeric': 0.15317851278442413, 'fraction_numerical': 0.005160684963640629, 'mean_word_length': 1.554823247453565, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 29, 'https://': 2, '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': '6155824', 'n_tokens_mistral': 1320, 'n_tokens_neox': 1301, 'n_words': 299}