MCPcopy Index your code
hub / github.com/sourcebot-dev/sourcebot / normalizeChoices

Function normalizeChoices

packages/setupWizard/src/tabCheckbox.ts:118–151  ·  view source on GitHub ↗
(
    choices: readonly (Separator | Value | Choice<Value>)[],
)

Source from the content-addressed store, hash-verified

116}
117
118function normalizeChoices<Value>(
119 choices: readonly (Separator | Value | Choice<Value>)[],
120): (NormalizedChoice<Value> | Separator)[] {
121 return choices.map((choice) => {
122 if (Separator.isSeparator(choice)) {
123 return choice;
124 }
125 if (typeof choice !== 'object' || choice === null || !('value' in (choice as object))) {
126 const name = String(choice);
127 return {
128 value: choice as Value,
129 name,
130 short: name,
131 checkedName: name,
132 disabled: false,
133 checked: false,
134 };
135 }
136 const c = choice as Choice<Value>;
137 const name = c.name ?? String(c.value);
138 const normalizedChoice: NormalizedChoice<Value> = {
139 value: c.value,
140 name,
141 short: c.short ?? name,
142 checkedName: c.checkedName ?? name,
143 disabled: c.disabled ?? false,
144 checked: c.checked ?? false,
145 };
146 if (c.description) {
147 normalizedChoice.description = c.description;
148 }
149 return normalizedChoice;
150 });
151}
152
153type TabCheckboxConfig<Value> = {
154 message: string;

Callers 1

tabCheckbox.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected