MCPcopy Create free account
hub / github.com/apache/fory / isDepthFreeField

Function isDepthFreeField

javascript/packages/core/lib/gen/struct.ts:38–53  ·  view source on GitHub ↗

* Returns true when a field's read cannot recurse and needs no depth tracking. * Covers leaf scalars, typed arrays, and collections/maps whose elements are all leaf types.

(typeInfo: TypeInfo)

Source from the content-addressed store, hash-verified

36 * Covers leaf scalars, typed arrays, and collections/maps whose elements are all leaf types.
37 */
38function isDepthFreeField(typeInfo: TypeInfo): boolean {
39 const id = typeInfo.typeId;
40 if (TypeId.isLeafTypeId(id)) return true;
41 // LIST / SET with leaf element type
42 if (id === TypeId.LIST || id === TypeId.SET) {
43 const inner = typeInfo.options?.inner;
44 return !!inner && TypeId.isLeafTypeId(inner.typeId);
45 }
46 // MAP with leaf key and value types
47 if (id === TypeId.MAP) {
48 const key = typeInfo.options?.key;
49 const value = typeInfo.options?.value;
50 return !!key && !!value && TypeId.isLeafTypeId(key.typeId) && TypeId.isLeafTypeId(value.typeId);
51 }
52 return false;
53}
54
55function compatibleReadTargetExpr(typeInfo: TypeInfo, expr: string): string {
56 const action = getCompatibleCollectionArrayReadAction(typeInfo);

Callers 2

isDepthFreeStructMethod · 0.85
readFieldMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected