MCPcopy Create free account
hub / github.com/AdbAutoPlayer/AdbAutoPlayer / updateCheckboxArray

Function updateCheckboxArray

src/lib/form/checkboxHelper.ts:5–20  ·  view source on GitHub ↗
(
  currentValue: string[],
  choice: string,
  isChecked: boolean,
)

Source from the content-addressed store, hash-verified

3 * Used by MultiCheckbox and ImageCheckbox components
4 */
5export function updateCheckboxArray(
6 currentValue: string[],
7 choice: string,
8 isChecked: boolean,
9): string[] {
10 // Ensure we have an array
11 const valueArray = Array.isArray(currentValue) ? currentValue : [];
12
13 if (isChecked) {
14 // Add choice if not already present
15 return valueArray.includes(choice) ? valueArray : [...valueArray, choice];
16 } else {
17 // Remove choice
18 return valueArray.filter((item) => item !== choice);
19 }
20}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected