<commit_before>(->
  ###*
  # @func waff#query.all
  # @alias waff#q.all
  # @alias waff#qq
  # @desc Query all elements
  # @param {String} selector='body' - CSS Selector
  # @param {Element} [root=document] - Element to perform query on
  # @param {Boolean} [single=false] - Specifies if the query is single
  # @example
  # var divs = waff.query.all('div')
  # var divs = waff.qq('div')
  # var divs = waff.q.all('div')
  # @returns {Element[]} Returns found elements
  ###
  querySelector = (qs, root, single) ->
    [root.querySelector qs] if single == true
    root.querySelectorAll qs
  queryElement = (qs, root, single) ->
    if waff.__has qs, '['
      querySelector qs, root, single
    else if /^[A-z0-9*-]+$/.test qs
      root.getElementsByTagName qs
    else if /^#[A-z0-9*-]+$/.test qs
      [document.getElementById qs.slice 1]
    else if /^\.[A-z0-9*-.]+$/.test qs
      root.getElementsByClassName (qs.replace /\./g, ' ').slice 1
    else
      querySelector qs, root, single
  queryAll = (qs = 'body', root = document, single = false) ->
    qs = '*' if qs == ''

    if waff.__isarray root
      s = @ps qs
      arr = waff.__toarray root
      ret = []
      _arr = []
      for element in arr
        if element instanceof Element
          _arr.push element
      arr = _arr
      if s.tag == '*'
        if single == true
          return arr[0]
        else
          return arr
      for element in arr
        pass = true
        if pass == true and s.tag != false and element.tagName.toLowerCase() != s.tag.toLowerCase()
          pass = false
        if pass == true and s.id != false and element.id != s.id
          pass = false
        if pass == true
          for c in s.class
            unless element.class.has c
              pass = false
        if pass == true and s.attr != false
          for attr, parsed of s.attr
            if pass == true
              switch parsed.operator
                when false
                  pass = element.hasAttribute attr
                when '='
                  pass = parsed.value == element.attr attr
                when '^='
                  pass = 0 == waff.__index element.attr(attr), parsed.value
                when '$='
                  v = element.attr attr
                  pass = -1 != v.indexOf parsed.value, v.length - parsed.value
                when '~='
                  pass = -1 != waff.__index element.attr(attr).split(' '), parsed.value
                when '|='
                  v = element.attr attr
                  pass = parsed.value == v
                  unless pass == true
                    pass = 0 == waff.__index v, parsed.value + '-'
                when '*='
                  pass = -1 != waff.__index element.attr(attr), parsed.value
        if pass == true
          if single == true
            return element
          ret.push element

      return ret
    return [ qs ] if qs instanceof Element
    if waff.__isarray qs
      arr = waff.__toarray qs
      _arr = []
      for qs, i in arr
        if qs instanceof Element
          return qs if single == true
          _arr.push qs
        else
          q = queryElement qs, root, single
          return q[0] if single == true
          _arr.push.apply _arr, q
      _arr
    else<commit_msg>Update all.coffee<commit_after>(->
  ###*
  # @func waff#query.all
  # @alias waff#q.all
  # @alias waff#qq
  # @desc Query all elements
  # @param {String} selector='body' - CSS Selector
  # @param {Element} [root=document] - Element to perform query on
  # @param {Boolean} [single=false] - Specifies if the query is single
  # @example
  # var divs = waff.query.all('div')
  # var divs = waff.qq('div')
  # var divs = waff.q.all('div')
  # @returns {Element[]} Returns found elements
  ###
  querySelector = (qs, root, single) ->
    [root.querySelector qs] if single == true
    root.querySelectorAll qs
  queryElement = (qs, root, single) ->
    if waff.__has qs, '['
      querySelector qs, root, single
    else if /^[A-z0-9*-]+$/.test qs
      root.getElementsByTagName qs
    else if /^#[A-z0-9*-]+$/.test qs
      [document.getElementById qs.slice 1]
    else if /^\.[A-z0-9*-.]+$/.test qs
      root.getElementsByClassName (qs.replace /\./g, ' ').slice 1
    else
      querySelector qs, root, single
  queryAll = (qs = 'body', root = document, single = false) ->
    qs = '*' if qs == ''

    if waff.__isarray root
      s = @ps qs
      arr = waff.__toarray root
      ret = []
      _arr = []
      for element in arr
        if element instanceof Element
          _arr.push element
      arr = _arr
      if s.tag == '*'
        if single == true
          return arr[0]
        else
          return arr
      for element in arr
        pass = true
        if pass == true and s.tag != false and element.tagName.toLowerCase() != s.tag.toLowerCase()
          pass = false
        if pass == true and s.id != false and element.id != s.id
          pass = false
        if pass == true
          for c in s.class
            unless element.class.has c
              pass = false
        if pass == true and s.attr != false
          for attr, parsed of s.attr
            if pass == true
              switch parsed.operator
                when false
                  pass = element.hasAttribute attr
                when '='
                  pass = parsed.value == element.attr attr
                when '^='
                  pass = 0 == waff.__index element.attr(attr), parsed.value
                when '$='
                  v = element.attr attr
                  pass = -1 != v.indexOf parsed.value, v.length - parsed.value
                when '~='
                  pass = -1 != waff.__index element.attr(attr).split(' '), parsed.value
                when '|='
                  v = element.attr attr
                  pass = parsed.value == v
                  unless pass == true
                    pass = 0 == waff.__index v, parsed.value + '-'
                when '*='
                  pass = -1 != waff.__index element.attr(attr), parsed.value
        if pass == true
          if single == true
            return element
          ret.push element

      return ret
    return if single == true then qs else [ qs ] if qs instanceof Element
    if waff.__isarray qs
      arr = waff.__toarray qs
      _arr = []
      for qs, i in arr
        if qs instanceof Element
          return qs if single == true
          _arr.push qs
        else
          q = queryElement qs, root, single
          return q[0] if single == true
          _arr.push.apply _arr, q
      _arr
    else
{'fraction_non_alphanumeric': 0.11380512198818003, 'fraction_numerical': 0.004546143355053796, 'mean_word_length': 1.5326170376055257, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '4699109', 'n_tokens_mistral': 1968, 'n_tokens_neox': 1918, 'n_words': 618}