MCPcopy Create free account
hub / github.com/LibPDF-js/core / getInheritableFieldName

Function getInheritableFieldName

src/document/forms/fields/factory.ts:68–100  ·  view source on GitHub ↗

* Get inheritable name value from field hierarchy.

(
  dict: PdfDict,
  key: string,
  registry: ObjectRegistry,
)

Source from the content-addressed store, hash-verified

66 * Get inheritable name value from field hierarchy.
67 */
68function getInheritableFieldName(
69 dict: PdfDict,
70 key: string,
71 registry: ObjectRegistry,
72): string | null {
73 let current: PdfDict | null = dict;
74 const visited = new Set<PdfDict>();
75 const resolve = registry.resolve.bind(registry);
76
77 while (current) {
78 if (visited.has(current)) {
79 break;
80 }
81
82 visited.add(current);
83
84 const value = current.getName(key, resolve);
85
86 if (value) {
87 return value.value;
88 }
89
90 const parent = current.getDict("Parent", resolve);
91
92 if (!parent) {
93 break;
94 }
95
96 current = parent;
97 }
98
99 return null;
100}
101
102/**
103 * Get inheritable number value from field hierarchy.

Callers 1

createFormFieldFunction · 0.85

Calls 4

getNameMethod · 0.65
getDictMethod · 0.65
hasMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected