<commit_before>
(function(exports) {
  var phantomizer_helper = function(){

    var html_utils = require("./html_utils").html_utils;

    this.get_r_config=function(rjs_base_url, requirejs_paths){
      var r_config = "";
      r_config += "<script>"
      r_config += "var requirejs = {baseUrl:'"+rjs_base_url+"',paths:"+JSON.stringify(requirejs_paths)+"};"
      //r_config += "var requirejs = {config:{baseUrl:'"+rjs_base_url+"',paths:"+JSON.stringify(requirejs_paths)+"}};"
      r_config += "</script>"
      return r_config;
    }
    /**
     * Inject requireJS
     *
     * @param rjs_base_url
     * @param rjs_url
     * @param buf
     * @param main_url
     * @returns {*}
     */
    this.inject_requirejs = function(rjs_base_url, rjs_url, requirejs_paths, buf, main_url){
      var ncontent = "";
      if( rjs_url.substring ) rjs_url = [rjs_url];
      for(var n in rjs_url ){
        if( buf.match(rjs_base_url+rjs_url[n]) != null ){
          var rjs_node = html_utils.find_rjs_nodes(buf, rjs_url[n], rjs_base_url)[0];
          ncontent = "";
          var r_config = this.get_r_config(rjs_base_url, requirejs_paths);
          ncontent += r_config
          ncontent += rjs_node.node+"";
          if( main_url ){
            ncontent += "<script >"
            ncontent += "require(['"+main_url+"']);"
            ncontent += "</script>"
          }
          buf = buf.replace(r_config,'');
          buf = buf.replace(rjs_node.node, ncontent)
          return buf;
        }
      }


      if( rjs_url.length > 0 ){
        if( main_url != null ){
          ncontent = "<script data-main=\""+main_url+"\" src='"+rjs_base_url+rjs_url[0]+"'></script>"
          var r_config = this.get_r_config(rjs_base_url, requirejs_paths);
          buf = buf.replace(r_config,'');
          buf = buf.replace("</body>", r_config+ncontent+"</body>")
        }
      }
      return buf
    };
    /**
     * Inject scripts before requirejs
     *
     * @param rjs_base_url
     * @param rjs_url
     * @param buf
     * @param injected
     * @returns {*}
     */
    this.inject_after_requirejs = function(rjs_base_url, rjs_url, requirejs_paths, buf, injected){
      var content = "";
      if( rjs_url.substring ) rjs_url = [rjs_url];
      for(var n in rjs_url ){
        if( buf.match(rjs_base_url+rjs_url[n]) != null ){
          var rjs_node = html_utils.find_rjs_nodes(buf, rjs_url[n], rjs_base_url)[0];
          content = "";
          var r_config = this.get_r_config(rjs_base_url, requirejs_paths);
          if( rjs_node.main ){
            content += "<script src='"+rjs_base_url+rjs_url[n]+"'></script>"
            if( injected && injected.indexOf(rjs_node.main)==-1 ){
              content += "<script >"
              content += "require(['"+injected+"'], function(){require(['"+rjs_node.main+"']);});"
              content += "</script>"
            }else{
              content += "<script >"
              content += "require(['"+rjs_node.main+"']);"
              content += "</script>"
            }
          }else{
            content += rjs_node.node+"";
            if( injected ){
              content += "<script >"
              content += "require(['"+injected+"']);"
              content += "</script>"
            }
          }
          buf = buf.replace(r_config,'');
          buf = buf.replace(rjs_node.node, r_config+content)
          return buf;
        }
      }
      if( rjs_url.length > 0 ){
        if( injected != null ){
          content = "<script data-main=\""+injected+"\" src='"+rjs_base_url+rjs_url[0]+"'></script>"
          var r_config = this.get_r_config(rjs_base_url, requirejs_paths);
          buf = buf.replace(r_config,'');
          buf = buf.replace("</body>", r_config+content+"</body>")
        }
      }
      return buf;
    }
    /**
     * Inject is_phantom variable to inject build status into DOM
     *
     * @param buf
     * @returns {XML|string}
     */<commit_msg>code style<commit_after>
(function(exports) {
  var phantomizer_helper = function(){

    var html_utils = require("./html_utils").html_utils;

    this.get_r_config=function(rjs_base_url, requirejs_paths){
      var r_config = "";
      r_config += "<script>"
      r_config += "var requirejs = {baseUrl:'"+rjs_base_url+"',paths:"+JSON.stringify(requirejs_paths)+"};"
      //r_config += "var requirejs = {config:{baseUrl:'"+rjs_base_url+"',paths:"+JSON.stringify(requirejs_paths)+"}};"
      r_config += "</script>"
      return r_config;
    }
    /**
     * Inject requireJS
     *
     * @param rjs_base_url
     * @param rjs_url
     * @param buf
     * @param main_url
     * @returns {*}
     */
    this.inject_requirejs = function(rjs_base_url, rjs_url, requirejs_paths, buf, main_url){
      var ncontent = "";
      if( rjs_url.substring ) rjs_url = [rjs_url];
      for(var n in rjs_url ){
        if( buf.match(rjs_base_url+rjs_url[n]) != null ){
          var rjs_node = html_utils.find_rjs_nodes(buf, rjs_url[n], rjs_base_url)[0];
          ncontent = "";
          var r_config = this.get_r_config(rjs_base_url, requirejs_paths);
          ncontent += r_config
          ncontent += rjs_node.node+"";
          if( main_url ){
            ncontent += "<script >"
            ncontent += "require(['"+main_url+"']);"
            ncontent += "</script>"
          }
          buf = buf.replace(r_config,'');
          buf = buf.replace(rjs_node.node, ncontent)
          return buf;
        }
      }


      if( rjs_url.length > 0 ){
        if( main_url != null ){
          ncontent = "<script data-main=\""+main_url+"\" src='"+rjs_base_url+rjs_url[0]+"'></script>"
          var r_config = this.get_r_config(rjs_base_url, requirejs_paths);
          buf = buf.replace(r_config,'');
          buf = buf.replace("</body>", r_config+ncontent+"</body>")
        }
      }
      return buf
    };
    /**
     * Inject scripts using requirejs
     *
     * @param rjs_base_url
     * @param rjs_url
     * @param buf
     * @param injected
     * @returns {*}
     */
    this.inject_after_requirejs = function(rjs_base_url, rjs_url, requirejs_paths, buf, injected){
      var content = "";
      if( rjs_url.substring ) rjs_url = [rjs_url];
      for(var n in rjs_url ){
        if( buf.match(rjs_base_url+rjs_url[n]) != null ){
          var rjs_node = html_utils.find_rjs_nodes(buf, rjs_url[n], rjs_base_url)[0];
          content = "";
          var r_config = this.get_r_config(rjs_base_url, requirejs_paths);
          if( rjs_node.main ){
            content += "<script src='"+rjs_base_url+rjs_url[n]+"'></script>";
            if( injected && injected.indexOf(rjs_node.main)==-1 ){
              content += "<script >";
              content += "require(['"+injected+"'], function(){require(['"+rjs_node.main+"']);});";
              content += "</script>";
            }else{
              content += "<script >";
              content += "require(['"+rjs_node.main+"']);";
              content += "</script>";
            }
          }else{
            content += rjs_node.node+"";
            if( injected ){
              content += "<script >";
              content += "require(['"+injected+"']);";
              content += "</script>";
            }
          }
          buf = buf.replace(r_config,'');
          buf = buf.replace(rjs_node.node, r_config+content);
          return buf;
        }
      }
      if( rjs_url.length > 0 ){
        if( injected != null ){
          content = "<script data-main=\""+injected+"\" src='"+rjs_base_url+rjs_url[0]+"'></script>"
          var r_config = this.get_r_config(rjs_base_url, requirejs_paths);
          buf = buf.replace(r_config,'');
          buf = buf.replace("</body>", r_config+content+"</body>")
        }
      }
      return buf;
    }
    /**
     * Inject is_phantom variable to inject build status into DOM
     *
     * @param buf
     * @returns {XML|string}
     */
{'fraction_non_alphanumeric': 0.16252052026771058, 'fraction_numerical': 0.0017678999873721429, 'mean_word_length': 2.14785373608903, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 47, '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': '325597', 'n_tokens_mistral': 2624, 'n_tokens_neox': 2593, 'n_words': 445}