Australia
Australia
Australia
ALT A code snippet showing how object-identity might work. ```ts import { identify } from "object-identity"; const filters = { status: new Set(["open", "draft"]), sort: { direction: "desc", field: "createdAt" }, }; useQuery({ queryKey: ["posts", identify(filters)], queryFn: () => fetchPosts(filters), }); ```
ALT A code snippet showing how it might be used for React.cache. ```ts import { identify } from "object-identity"; import { cache } from "react"; const refs = new Map<string, object>(); function stable<T extends object>(value: T): T { const key = identify(value); refs.set(key, refs.get(key) ?? value); return refs.get(key) as T; } const get_posts = cache(async (filters: object) => { return db.posts.findMany(filters); }); // Same shape → same reference → cache hit. await get_posts(stable({ status: "draft", limit: 10 })); await get_posts(stable({ limit: 10, status: "draft" })); ```