30 lines
842 B
TypeScript
30 lines
842 B
TypeScript
import type { Query } from '@tanstack/react-query';
|
|
import type { ClassValue } from 'clsx';
|
|
// eslint-disable-next-line unicorn/prefer-node-protocol
|
|
import { Buffer } from 'buffer';
|
|
import { clsx } from 'clsx';
|
|
import { twMerge } from 'tailwind-merge';
|
|
|
|
export function cn(...inputs: ClassValue[]) {
|
|
return twMerge(clsx(inputs));
|
|
}
|
|
|
|
export function base64ToUtf8(base64: string): string {
|
|
return new TextDecoder('utf-8').decode(
|
|
Uint8Array.from(Buffer.from(base64, 'base64')),
|
|
);
|
|
}
|
|
|
|
export function utf8ToBase64(utf8: string): string {
|
|
return Buffer.from(utf8, 'utf-8').toString('base64');
|
|
}
|
|
|
|
export function invalidateBlurry(id: string) {
|
|
return {
|
|
predicate: (query: Query<unknown, Error, unknown, readonly unknown[]>) => {
|
|
const key = query.queryKey[0] as { _id: string };
|
|
return key?._id === id;
|
|
},
|
|
};
|
|
}
|