<commit_before>/**
 * @param {HTMLElement | Array | String} target
 * @param {Document} document
 */
export const domArray = (target, document) => {
  if (typeof target === 'string') return Array.from(document.querySelectorAll(target))
  if (target instanceof HTMLElement) return [target]
  if (target.jquery) return target.toArray()
  if (Array.isArray(target)) return target
  return []
}

/**
 * @param { HTMLElement | String } target
 * @param { Document } document
 * @returns { HTMLElement }
 */
export const domSelector = (target, document) => {
  if (typeof target === 'string') return document.querySelector(target)
  if (target instanceof HTMLElement) return target
  if (target.jquery) return target[0]
  return target
}
<commit_msg>fix: Make the domArray and domSelector compatible with different windows<commit_after>/**
 * @param {HTMLElement | Array | String} target
 * @param {Document} document
 */
export const domArray = (target, document) => {
  if (typeof target === 'string') return Array.from(document.querySelectorAll(target))
  if (target.tagName) return [target]
  if (target.jquery) return target.toArray()
  if (Array.isArray(target)) return target
  return []
}

/**
 * @param { HTMLElement | String } target
 * @param { Document } document
 * @returns { HTMLElement }
 */
export const domSelector = (target, document) => {
  if (typeof target === 'string') return document.querySelector(target)
  if (target.tagName) return target
  if (target.jquery) return target[0]
  return target
}

{'fraction_non_alphanumeric': 0.13249835201054713, 'fraction_numerical': 0.0013183915622940012, 'mean_word_length': 4.580882352941177, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2590244', 'n_tokens_mistral': 431, 'n_tokens_neox': 444, 'n_words': 139}