export function isPrimitive(value: any) { return ( value === undefined || value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint" || typeof value === "symbol" ); } export function isObject(value: any) { if (isPrimitive(value)) return false; if (value && value.constructor) { return value.constructor.name === "Object"; } return typeof value === "object" && value !== null; } export function clone(obj: T): T { if (isPrimitive(obj)) return obj; if (Array.isArray(obj)) { return obj.map((item) => clone(item)) as unknown as T; } if (isObject(obj)) { const cloned = Object.create(null); for (const key in obj) { cloned[key] = clone(obj[key]); } return cloned; } return obj; }