export function debounce(fn, delay) {
  let timer = null

  return function () {
    clearTimeout(timer)
    let context = this
    let args = arguments

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