MCPcopy Index your code
hub / github.com/anomalyco/models.dev / compare

Function compare

packages/core/script/generate-digitalocean.ts:560–566  ·  view source on GitHub ↗
(field: string, oldVal: unknown, newVal: unknown)

Source from the content-addressed store, hash-verified

558 const EPSILON = 0.001;
559
560 const compare = (field: string, oldVal: unknown, newVal: unknown) => {
561 if (oldVal === undefined && newVal === undefined) return;
562 const isDiff = field.startsWith("cost.")
563 ? Math.abs((oldVal as number ?? 0) - (newVal as number ?? 0)) > EPSILON
564 : JSON.stringify(oldVal) !== JSON.stringify(newVal);
565 if (isDiff) changes.push({ field, oldValue: formatValue(oldVal), newValue: formatValue(newVal) });
566 };
567
568 compare("name", existing.name, merged.name);
569 compare("reasoning", existing.reasoning, merged.reasoning);

Callers 1

detectChangesFunction · 0.70

Calls 1

formatValueFunction · 0.70

Tested by

no test coverage detected