MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / ensureFieldArrayKeys

Function ensureFieldArrayKeys

packages/core/src/forms/internal/arrayState.ts:63–80  ·  view source on GitHub ↗
(
  field: keyof T,
  length: number,
  fieldArrayKeysRef: FieldArrayKeysRef<T>,
  fieldArrayKeyCounterRef: CounterRef,
)

Source from the content-addressed store, hash-verified

61}
62
63function ensureFieldArrayKeys<T extends Record<string, unknown>>(
64 field: keyof T,
65 length: number,
66 fieldArrayKeysRef: FieldArrayKeysRef<T>,
67 fieldArrayKeyCounterRef: CounterRef,
68): string[] {
69 const existing = [...(fieldArrayKeysRef.current[field] ?? [])];
70
71 if (existing.length > length) {
72 existing.length = length;
73 }
74 while (existing.length < length) {
75 existing.push(nextFieldArrayKey(String(field), fieldArrayKeyCounterRef));
76 }
77
78 fieldArrayKeysRef.current[field] = existing;
79 return existing;
80}
81
82function appendFieldArrayKey<T extends Record<string, unknown>>(
83 field: keyof T,

Callers 1

useFieldArrayFunction · 0.85

Calls 2

nextFieldArrayKeyFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected