<commit_before>/*\
 * $
 [ object ]
 * Global namespace for using Kimbo functions
\*/

/*\
 * $(…)
 * Kimbo object collection.
 * All methods called from a Kimbo collection affects all elements in it.
\*/
function Kimbo(selector, context) {
  if (!(this instanceof Kimbo)) {
    return new Kimbo(selector, context);
  }

  var elem, match;

  // no selector, return empty Kimbo object
  if (!selector) {
    return this;
  }

  // already a dom element
  if (selector.nodeType) {
    this[0] = selector;
    this.length = 1;
    return this;
  }

  // asume a css selector, query the dom
  if (typeof selector === 'string') {

    // optimize finding body or head elements
    if (!context && /^(body|head)$/.test(selector)) {
      this[0] = document[selector];
      this.length = 1;
      return this;
    }

    match = r_id.exec(selector);

    // fast handle $('#id');
    if (match && match[1]) {
      elem = document.getElementById(match[1]);

      if (elem) {
        this[0] = elem;
        this.length = 1;
      }

      return this;
    }
<commit_msg>define var at the top<commit_after>/*\
 * $
 [ object ]
 * Global namespace for using Kimbo functions
\*/

/*\
 * $(…)
 * Kimbo object collection.
 * All methods called from a Kimbo collection affects all elements in it.
\*/
function Kimbo(selector, context) {
  var elem, match;

  if (!Kimbo.isKimbo(this)) {
    return new Kimbo(selector, context);
  }

  // no selector, return empty Kimbo object
  if (!selector) {
    return this;
  }

  // already a dom element
  if (selector.nodeType) {
    this[0] = selector;
    this.length = 1;
    return this;
  }

  // asume a css selector, query the dom
  if (typeof selector === 'string') {

    // optimize finding body or head elements
    if (!context && /^(body|head)$/.test(selector)) {
      this[0] = document[selector];
      this.length = 1;
      return this;
    }

    match = r_id.exec(selector);

    // handle $('#id');
    if (match && match[1]) {
      elem = document.getElementById(match[1]);

      if (elem) {
        this[0] = elem;
        this.length = 1;
      }

      return this;
    }

{'fraction_non_alphanumeric': 0.14218676677616143, 'fraction_numerical': 0.007508212106992022, 'mean_word_length': 2.3364632237871676, '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': '45803', 'n_tokens_mistral': 696, 'n_tokens_neox': 665, 'n_words': 209}