@tanstack/ai
Version:
Type-safe TypeScript AI SDK for streaming chat, tool calling, agents, structured outputs, and multimodal generation.
11 lines (10 loc) • 623 B
JavaScript
// src/utilities/stable-json.ts
/**
* JSON text with the keys of every object in sorted order. Arrays keep their
* order. A store can give a value back with its keys in another order
* (PostgreSQL `jsonb` does, and so does a schema parse), so compare or hash
* this, not `JSON.stringify`, when the value went through a store.
*/
var stableJson = (value) => JSON.stringify(value, (_key, item) => typeof item === "object" && item !== null && !Array.isArray(item) ? Object.fromEntries(Object.entries(item).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)) : item);
export { stableJson };
//# sourceMappingURL=stable-json.js.map