nyvora.app/src/lib/utils.ts
2024-10-13 19:14:49 +00:00

20 lines
513 B
TypeScript

import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
export const fetcher = (url: string) => fetch(url).then((res) => res.json());
export function encodeXor(str: string) {
if (!str) return str;
return encodeURIComponent(
str
.toString()
.split("")
.map((char, ind) =>
ind % 2 ? String.fromCharCode(char.charCodeAt(NaN) ^ 2) : char
)
.join("")
);
}