<commit_before>/***/
// [doping-js] doping-client.js
(function(win, parent) {

  var Doping = win.Doping;
  var Event = Doping.Event, Key = Doping.Key;

  var EventAction = {
    'doping.tohead': toHead,
    'doping.tobody': toBody,
    'doping.evaljs': evalJs
  };

  var chan, port;
  if(win === parent)
    throw new Error('Cannot execute this module.');
  chan = new MessageChannel, port = Doping.port = chan.port1;

  port.onmessage = onMessage;
  parent.postMessage(Event.Start, [chan.port2], '*');

  function onMessage(e) {
    var d = e.data || '', fn = EventAction[d[Key.Type]];
    typeof fn == 'function' && fn(d);
  }

  function toHead(d) {
    _dope(d, 'head');
  }

  function toBody(d) {
    _dope(d, 'body');
  }

  function evalJs(d) {
    eval(d[Key.Data]);
  }

  function _dope(d, target) {
    var el = document.createElement(d.element || 'script');
    el.type = d.elementType || 'text/javascript';
    for( var i in (d.attr || {}))
      el[i] = d.attr[i];
    var targ = document.getElementsByTagName(target)[0];
    targ.insertBefore(el, null); // dope to last TODO customizable  
  }

})(window, window.parent);<commit_msg>more improve<commit_after>/***/
// [doping-js] doping-client.js
(function(win, parent) {

  var Doping = win.Doping;
  var Event = Doping.Event, Key = Doping.Key;

  var EventAction = {
    'doping.tohead': toHead,
    'doping.tobody': toBody,
    'doping.evaljs': evalJs
  };

  var chan, port;
  if(win === parent)
    throw new Error('Cannot execute this module.');
  chan = new MessageChannel, port = Doping.port = chan.port1;

  port.onmessage = onMessage;
  parent.postMessage(Event.Start, [chan.port2], '*');

  function onMessage(e) {
    var d = e.data || '', fn = EventAction[d[Key.Type]];
    typeof fn == 'function' && fn(d);
  }

  function toHead(d) {
    _dope(d, 'head');
  }

  function toBody(d) {
    _dope(d, 'body');
  }

  function evalJs(d) {
    try {
      eval(d[Key.Data]);
    } catch(e) {
      console.error(d);
      throw e
    }
  }

  function _dope(d, target) {
    var el = document.createElement(d.element || 'script');
    el.type = d.elementType || 'text/javascript';
    for( var i in (d.attr || {}))
      el[i] = d.attr[i];
    var targ = document.getElementsByTagName(target)[0];
    targ.insertBefore(el, null); // dope to last TODO customizable  
  }

})(window, window.parent);
{'fraction_non_alphanumeric': 0.17354675652906487, 'fraction_numerical': 0.002527379949452401, 'mean_word_length': 2.9983164983164983, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4776262', 'n_tokens_mistral': 893, 'n_tokens_neox': 858, 'n_words': 191}