<commit_before>'use strict';
'browser-only';

/**
 * @license
 * (c) 2014 Cluster Labs, Inc. https://cluster.co/
 * License: MIT
 */

var util = skit.platform.util;
var zest = skit.thirdparty.zest;


var ELEMENT_NODE_TYPE = 1;


var ElementWrapper = function(element) {
  this.element = element;
};


ElementWrapper.elementsFromHtml = function(html) {
  var div = document.createElement('div');
  div.innerHTML = html;
  return (new ElementWrapper(div)).children();
};


ElementWrapper.fromHtml = function(html) {
  return ElementWrapper.elementsFromHtml(html)[0];
};


ElementWrapper.prototype.children = function() {
  var filtered;
  if (this.element.children) {
    filtered = util.toArray(this.element.children);
  } else {
    filtered = util.filter(this.element.childNodes, function(node) {
      return node.nodeType == ELEMENT_NODE_TYPE;
    });
  }

  return util.map(filtered, function(element) {
    return new ElementWrapper(element);
  });
};


ElementWrapper.prototype.contains = function(otherEl) {
  var current = otherEl.element || otherEl;
  while (current) {
    if (current == this.element) {
      return true;
    }
    current = current.parentNode;
  }
  return false;
};


ElementWrapper.prototype.parent = function() {
  if (this.element.parentNode && this.element.parentNode.nodeType == ELEMENT_NODE_TYPE) {
    return new ElementWrapper(this.element.parentNode);
  }
  return null;
};


ElementWrapper.prototype.matches = function(selector) {
  return zest.matches(this.element, selector);
};


ElementWrapper.prototype.find = function(selector) {
  return util.map(zest(selector, this.element), function(el) {
    return new ElementWrapper(el);
  });
};


ElementWrapper.prototype.get = function(selector) {
  var found = this.find(selector);
  return found.length ? found[0] : null;
};


ElementWrapper.prototype.$ = ElementWrapper.prototype.find;


ElementWrapper.prototype.first = function(selector) {
  var children = this.children();
  return children.length ? children[0] : null;
};


ElementWrapper.prototype.up = function(selector) {
  var current = this;
  while (current && !current.matches(selector)) {
    current = current.parent();
  }
  return current;
};


ElementWrapper.prototype.remove = function() {
  this.element.parentNode.removeChild(this.element);
};


ElementWrapper.prototype.replaceWith = function(htmlOrElement) {
  var replacement;
  if (typeof htmlOrElement == 'string') {
    replacement = ElementWrapper.fromHtml(htmlOrElement).element;
  } else {
    replacement = htmlOrElement.element || htmlOrElement;
  }

  this.element.parentNode.insertBefore(replacement, this.element);
  this.element.parentNode.removeChild(this.element);
  this.element = replacement;
};


ElementWrapper.prototype.replaceChildren = function(htmlOrElement) {
  var replacement;
  if (typeof htmlOrElement == 'string') {
    replacement = ElementWrapper.fromHtml(htmlOrElement).element;
  } else {
    replacement = htmlOrElement.element || htmlOrElement;
  }

  for (var i = this.element.childNodes.length - 1; i >= 0; i--) {
    this.element.removeChild(this.element.childNodes[i]);
  }
  for (var i = 0, len = replacement.childNodes.length; i < len; i++) {
    var child = replacement.childNodes[0];
    replacement.removeChild(child);
    this.element.appendChild(child);
  }
};


ElementWrapper.prototype.classes = function() {
  return util.trim(this.element.className).split(/\s+/);
};<commit_msg>Make replaceChildren optionally just replace the children with the given element rather than swapping in its children.<commit_after>'use strict';
'browser-only';

/**
 * @license
 * (c) 2014 Cluster Labs, Inc. https://cluster.co/
 * License: MIT
 */

var util = skit.platform.util;
var zest = skit.thirdparty.zest;


var ELEMENT_NODE_TYPE = 1;


var ElementWrapper = function(element) {
  this.element = element;
};


ElementWrapper.elementsFromHtml = function(html) {
  var div = document.createElement('div');
  div.innerHTML = html;
  return (new ElementWrapper(div)).children();
};


ElementWrapper.fromHtml = function(html) {
  return ElementWrapper.elementsFromHtml(html)[0];
};


ElementWrapper.prototype.children = function() {
  var filtered;
  if (this.element.children) {
    filtered = util.toArray(this.element.children);
  } else {
    filtered = util.filter(this.element.childNodes, function(node) {
      return node.nodeType == ELEMENT_NODE_TYPE;
    });
  }

  return util.map(filtered, function(element) {
    return new ElementWrapper(element);
  });
};


ElementWrapper.prototype.contains = function(otherEl) {
  var current = otherEl.element || otherEl;
  while (current) {
    if (current == this.element) {
      return true;
    }
    current = current.parentNode;
  }
  return false;
};


ElementWrapper.prototype.parent = function() {
  if (this.element.parentNode && this.element.parentNode.nodeType == ELEMENT_NODE_TYPE) {
    return new ElementWrapper(this.element.parentNode);
  }
  return null;
};


ElementWrapper.prototype.matches = function(selector) {
  return zest.matches(this.element, selector);
};


ElementWrapper.prototype.find = function(selector) {
  return util.map(zest(selector, this.element), function(el) {
    return new ElementWrapper(el);
  });
};


ElementWrapper.prototype.get = function(selector) {
  var found = this.find(selector);
  return found.length ? found[0] : null;
};


ElementWrapper.prototype.$ = ElementWrapper.prototype.find;


ElementWrapper.prototype.first = function(selector) {
  var children = this.children();
  return children.length ? children[0] : null;
};


ElementWrapper.prototype.up = function(selector) {
  var current = this;
  while (current && !current.matches(selector)) {
    current = current.parent();
  }
  return current;
};


ElementWrapper.prototype.remove = function() {
  this.element.parentNode.removeChild(this.element);
};


ElementWrapper.prototype.replaceWith = function(htmlOrElement) {
  var replacement;
  if (typeof htmlOrElement == 'string') {
    replacement = ElementWrapper.fromHtml(htmlOrElement).element;
  } else {
    replacement = htmlOrElement.element || htmlOrElement;
  }

  this.element.parentNode.insertBefore(replacement, this.element);
  this.element.parentNode.removeChild(this.element);
  this.element = replacement;
};


ElementWrapper.prototype.replaceChildren = function(htmlOrElement, opt_withChildren) {
  var replacement;
  if (typeof htmlOrElement == 'string') {
    replacement = ElementWrapper.fromHtml(htmlOrElement).element;
  } else {
    replacement = htmlOrElement.element || htmlOrElement;
  }

  for (var i = this.element.childNodes.length - 1; i >= 0; i--) {
    this.element.removeChild(this.element.childNodes[i]);
  }

  if (!opt_withChildren) {
    this.element.appendChild(replacement);
  } else {
    for (var i = 0, len = replacement.childNodes.length; i < len; i++) {
      var child = replacement.childNodes[0];
      replacement.removeChild(child);
      this.element.appendChild(child);
    }
  }
};


ElementWrapper.prototype.classes = function() {
  return util.trim(this.element.className).split(/\s+/);
};
{'fraction_non_alphanumeric': 0.13406562455992113, 'fraction_numerical': 0.0033798056611744824, 'mean_word_length': 4.214390602055801, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3609769', 'n_tokens_mistral': 2157, 'n_tokens_neox': 2122, 'n_words': 417}