<commit_before># jQuery module for a mock console that can be controlled through automated
# tests.
#
# FEATURES:
# * Can be used with a 'shell script' that executes each console command one
#   by one.
# * Buffers output and asynchronously sends it to a server running locally.

$ = jQuery

$.fn.console = (config) ->
  outBuffer = ""
  bufferSize = 1024
  commands = []
  uploading = false
  isComplete = false

  # Helper function for making errors purty.
  getErrorDetails = (url, type, data, textStatus, errorThrown) ->
    "Error during HTTP " + type + " to server.\n" +
    "---------------------------------\n" +
    "Details:\n" +
    "  URL: " + url + "\n" +
    "  Error Type: " + textStatus + "\n" +
    "  Additional Error Info: " + errorThrown + "\n" +
    "  Data: '" + data + "'\n"

  # All errors involving GET/PUT statements during benchmarks indicate failure.
  getFromServer = (url, doneFn) ->
    $.ajax({
      url: url
    }).done(doneFn).fail(
      (data, textStatus, errorThrown) ->
        printErrorInBrowser(
          getErrorDetails(url, "POST", data, textStatus, errorThrown))
    )

  postToServer = (url, data, doneFn) ->
    alert('"' + outBuffer + '"')
    $.ajax({
      type: "POST"
      url: url
      data: outBuffer
    }).done(doneFn).fail(
      (data, textStatus, errorThrown) ->
        printErrorInBrowser(
          getErrorDetails(url, "POST", data, textStatus, errorThrown))
    )<commit_msg>Debug alert, no!<commit_after># jQuery module for a mock console that can be controlled through automated
# tests.
#
# FEATURES:
# * Can be used with a 'shell script' that executes each console command one
#   by one.
# * Buffers output and asynchronously sends it to a server running locally.

$ = jQuery

$.fn.console = (config) ->
  outBuffer = ""
  bufferSize = 1024
  commands = []
  uploading = false
  isComplete = false

  # Helper function for making errors purty.
  getErrorDetails = (url, type, data, textStatus, errorThrown) ->
    "Error during HTTP " + type + " to server.\n" +
    "---------------------------------\n" +
    "Details:\n" +
    "  URL: " + url + "\n" +
    "  Error Type: " + textStatus + "\n" +
    "  Additional Error Info: " + errorThrown + "\n" +
    "  Data: '" + data + "'\n"

  # All errors involving GET/PUT statements during benchmarks indicate failure.
  getFromServer = (url, doneFn) ->
    $.ajax({
      url: url
    }).done(doneFn).fail(
      (data, textStatus, errorThrown) ->
        printErrorInBrowser(
          getErrorDetails(url, "POST", data, textStatus, errorThrown))
    )

  postToServer = (url, data, doneFn) ->
    $.ajax({
      type: "POST"
      url: url
      data: outBuffer
    }).done(doneFn).fail(
      (data, textStatus, errorThrown) ->
        printErrorInBrowser(
          getErrorDetails(url, "POST", data, textStatus, errorThrown))
    )
{'fraction_non_alphanumeric': 0.15416958654519972, 'fraction_numerical': 0.002803083391730904, 'mean_word_length': 2.4732360097323602, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '4792319', 'n_tokens_mistral': 893, 'n_tokens_neox': 870, 'n_words': 270}