MCPcopy Create free account
hub / github.com/anomalyco/models.dev / stable

Function stable

packages/core/src/sync/index.ts:611–627  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

609}
610
611function stable(value: unknown): string {
612 if (Array.isArray(value)) {
613 const items = value.map(stable);
614 const ordered = value.every((item) => item === null || typeof item !== "object")
615 ? items.sort()
616 : items;
617 return `[${ordered.join(",")}]`;
618 }
619 if (value !== null && typeof value === "object") {
620 return `{${Object.entries(value)
621 .filter(([, item]) => item !== undefined)
622 .sort(([a], [b]) => a.localeCompare(b))
623 .map(([key, item]) => `${JSON.stringify(key)}:${stable(item)}`)
624 .join(",")}}`;
625 }
626 return JSON.stringify(value);
627}
628
629function stripUndefined<T>(value: T): T {
630 if (Array.isArray(value)) {

Callers 2

syncProviderFunction · 0.70
sameModelFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected