export const debounce = (fn: Function, delay: number = 300): any => {
  let timer = 0
  const debounced = (...args: any[]): void => {
    if (!args) args = []
    clearTimeout(timer)

    timer = setTimeout(() => {
      fn.apply(fn, args)
    }, delay)
  }

  return debounced
}
