type DebouncedFunction<F extends (...args: any[]) => any> = (
  ...args: Parameters<F>
) => ReturnType<F> | void;



export function debounce<F extends (...args: any[]) => any>(
  func: F,
  wait: number
): DebouncedFunction<F> {
  let timeoutId: ReturnType<typeof setTimeout>;

  return function executedFunction(...args: Parameters<F>) {
    clearTimeout(timeoutId);

    timeoutId = setTimeout(() => {
      func(...args);
    }, wait);
  };
}

type HttpException = {
  status: number;
  message: string;
  data?: any;
};

export const getErrorMessage = (error: HttpException) => {
  return error.message;
};

export const getErrorData = (error: HttpException) => {
  return error.data;
};

export const getErrorStatus = (error: HttpException) => {
  return error.status;
};


