function debounce(fn, time) {
  let timeout = 0;

  return function () {
    // @ts-ignore
    const self = this;
    // eslint-disable-next-line prefer-rest-params
    const args = arguments;

    const functionCall = function functionCall() {
      return fn.apply(self, args);
    };

    clearTimeout(timeout);

    // @ts-ignore
    timeout = setTimeout(functionCall, time);
  };
}
@param {function} fn
@param {number} time
@returns {(function(): void)|*}