/**
 * KRA - Event Utility
 * Add and remove event listeners
 */
export function addEventListen(
  target: EventTarget,
  event: string,
  handler: EventListenerOrEventListenerObject,
  capture = false
) {
  if (target.addEventListener && typeof target.addEventListener === 'function') {
    target.addEventListener(event, handler, capture);
  }
}

export function removeEventListen(
  target: EventTarget,
  event: string,
  handler: EventListenerOrEventListenerObject,
  capture = false
) {
  if (target.removeEventListener && typeof target.removeEventListener === 'function') {
    target.removeEventListener(event, handler, capture);
  }
}

export default {
  addEventListen,
  removeEventListen,
};
