<commit_before>import * as classy from './classy'

// ┌─────┐
// │ DOM │
// └─────┘
// Handles dom nodes

// returns closest element up the DOM tree matching a given class
export function closest (className, context) {
  var result, current;
  for (current = context; current; current = current.parentNode) {
    if (current.nodeType === 1 && classy.has(current, className)) {
      result = current;
      break;
    }
  }
  return current;
}

// turn a domNodeList into an array
export function nodeListToArray (domNodeList) {
  return Array.prototype.slice.call(domNodeList);
}

// Finds all the elements inside a node, or the document and returns them as an array
export function findElements (query, domNode) {
  var context = domNode || document;
  var elements = context.querySelectorAll(query);
  return nodeListToArray(elements);
}<commit_msg>check if domNodeList is already an array inside of dom.toArray()<commit_after>import * as classy from './classy'

// ┌─────┐
// │ DOM │
// └─────┘
// Handles dom nodes

// returns closest element up the DOM tree matching a given class
export function closest (className, context) {
  var result
  var current
  for (current = context; current; current = current.parentNode) {
    if (current.nodeType === 1 && classy.has(current, className)) {
      result = current
      break
    }
  }
  return current
}

// turn a domNodeList into an array
export function nodeListToArray (domNodeList) {
  if (Array.isArray(domNodeList)) {
    return domNodeList
  }
  return Array.prototype.slice.call(domNodeList)
}

// Finds all the elements inside a node, or the document and returns them as an array
export function findElements (query, domNode) {
  var context = domNode || document
  var elements = context.querySelectorAll(query)
  return nodeListToArray(elements)
}
{'fraction_non_alphanumeric': 0.11074380165289256, 'fraction_numerical': 0.0011019283746556473, 'mean_word_length': 3.7168831168831167, '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': '473602', 'n_tokens_mistral': 533, 'n_tokens_neox': 530, 'n_words': 194}