export function addGlobalEventListener(
    type: string,
    selector: string,
    callback: (arg0: Event) => void,
    options: boolean | AddEventListenerOptions,
    parent = document
): void {
  parent.addEventListener(
      type,
      e => {
        // @ts-ignore
        if (e.target.matches(selector)) callback(e)
      },
      options
  )
}

export function qs(selector: string, parent = document): Element {
  return parent.querySelector(selector)
}

export function qsa(selector: string, parent = document): Element[] {
  return [...parent.querySelectorAll(selector)]
}
