2023-11-23 11:51:47 +00:00
|
|
|
import { clsx, type ClassValue } from "clsx";
|
|
|
|
import { twMerge } from "tailwind-merge";
|
|
|
|
|
2023-01-26 18:12:20 +00:00
|
|
|
export const debounce = (func: any, wait: number, immediate: boolean = false) => {
|
|
|
|
let timeout: any;
|
2023-03-15 06:14:44 +00:00
|
|
|
|
2023-01-26 18:12:20 +00:00
|
|
|
return function executedFunction(...args: any) {
|
|
|
|
const later = () => {
|
|
|
|
timeout = null;
|
|
|
|
if (!immediate) func(...args);
|
|
|
|
};
|
|
|
|
|
|
|
|
const callNow = immediate && !timeout;
|
|
|
|
|
|
|
|
clearTimeout(timeout);
|
|
|
|
|
|
|
|
timeout = setTimeout(later, wait);
|
|
|
|
|
|
|
|
if (callNow) func(...args);
|
|
|
|
};
|
|
|
|
};
|
2023-09-13 14:51:02 +00:00
|
|
|
|
2023-11-08 15:01:46 +00:00
|
|
|
export const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL ? process.env.NEXT_PUBLIC_API_BASE_URL : "";
|
2023-11-23 11:51:47 +00:00
|
|
|
|
|
|
|
export const cn = (...inputs: ClassValue[]) => twMerge(clsx(inputs));
|