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

Function normalizeBooleanArray

packages/core/src/forms/internal/state.ts:166–184  ·  view source on GitHub ↗
(
  value: FieldBooleanValue | undefined,
  size: number,
  defaultValue: boolean,
)

Source from the content-addressed store, hash-verified

164}
165
166export function normalizeBooleanArray(
167 value: FieldBooleanValue | undefined,
168 size: number,
169 defaultValue: boolean,
170): boolean[] {
171 if (Array.isArray(value)) {
172 const next = value.slice(0, size);
173 while (next.length < size) {
174 next.push(defaultValue);
175 }
176 return next;
177 }
178
179 if (value === true || value === false) {
180 return Array.from({ length: size }, () => value);
181 }
182
183 return Array.from({ length: size }, () => defaultValue);
184}
185
186export function normalizeErrorArray(
187 value: FieldErrorValue | undefined,

Callers 3

appendFunction · 0.85
removeFunction · 0.85
moveFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected