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

Function fingerprintDeclarations

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

Source from the content-addressed store, hash-verified

589 nodes.map((node) => node.getText().replace(/\/\*\*[\s\S]*?\*\//g, "").replace(/\s+/g, " ").trim()).join("\n")
590
591const fingerprintDeclarations = (declarations: ReadonlyArray<DeclarationModel>): string => {
592 const normalize = (value: unknown, parent?: string): unknown => {
593 if (Array.isArray(value)) {
594 return value.map((entry) => normalize(entry, parent))
595 }
596 if (value !== null && typeof value === "object") {
597 const input = value as Record<string, unknown>
598 return Object.fromEntries(
599 Object.entries(input).flatMap(([key, entry]) => {
600 if ((parent === "parameters" && key === "name") || key === "displayName") {
601 return []
602 }
603 return [[key, normalize(entry, key)]]
604 })
605 )
606 }
607 return value
608 }
609 return fingerprint(
610 declarations.map((declaration) => ({
611 ...declaration,
612 name: "<export>",
613 parameters: declaration.parameters?.map((parameter) => ({ ...parameter, name: "<parameter>" }))
614 })).map((declaration) => normalize(declaration))
615 )
616}
617
618interface PendingEntity {
619 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