code: function debounce(fn, time) {
    let timeoutId
  
    function cancel() {
      if (timeoutId) {
        clearTimeout(timeoutId)
      }
    }
  
    function wrapper(...args) {
      cancel()
      timeoutId = setTimeout(() => {
        timeoutId = null
        fn(...args)
      }, time)
    }
  
    wrapper.cancel = cancel
  
    return wrapper
  }
docs: Simple debounce implementation. Will call the given
  function once after the time given has passed since
  it was last called.
  @param {Function} fn the function to call after the time
  @param {Number} time the time to wait
  @return {Function} the debounced function