MCPcopy Create free account
hub / github.com/Effect-TS/effect / fingerprintDeclarations

Function fingerprintDeclarations

packages/tools/api-diff/src/Snapshot.ts:607–632  ·  view source on GitHub ↗
(declarations: ReadonlyArray<DeclarationModel>)

Source from the content-addressed store, hash-verified

605 nodes.map((node) => node.getText().replace(/\/\*\*[\s\S]*?\*\//g, "").replace(/\s+/g, " ").trim()).join("\n")
606
607const fingerprintDeclarations = (declarations: ReadonlyArray<DeclarationModel>): string => {
608 const normalize = (value: unknown, parent?: string): unknown => {
609 if (Array.isArray(value)) {
610 return value.map((entry) => normalize(entry, parent))
611 }
612 if (value !== null && typeof value === "object") {
613 const input = value as Record<string, unknown>
614 return Object.fromEntries(
615 Object.entries(input).flatMap(([key, entry]) => {
616 if ((parent === "parameters" && key === "name") || key === "displayName") {
617 return []
618 }
619 return [[key, normalize(entry, key)]]
620 })
621 )
622 }
623 return value
624 }
625 return fingerprint(
626 declarations.map((declaration) => ({
627 ...declaration,
628 name: "<export>",
629 parameters: declaration.parameters?.map((parameter) => ({ ...parameter, name: "<parameter>" }))
630 })).map((declaration) => normalize(declaration))
631 )
632}
633
634interface PendingEntity {
635 readonly symbol: ts.Symbol

Callers 1

extractSnapshotFunction · 0.85

Calls 3

fingerprintFunction · 0.90
normalizeFunction · 0.70
mapMethod · 0.45

Tested by

no test coverage detected