MCPcopy Create free account
hub / github.com/coder/mux / parseStringArray

Function parseStringArray

src/common/preferences/userPreferenceParsing.ts:21–38  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

19}
20
21export function parseStringArray(value: unknown): string[] | undefined {
22 if (!Array.isArray(value)) {
23 return undefined;
24 }
25
26 const out: string[] = [];
27 const seen = new Set<string>();
28 for (const item of value) {
29 const parsed = parseNonEmptyString(item);
30 if (!parsed || seen.has(parsed)) {
31 continue;
32 }
33 seen.add(parsed);
34 out.push(parsed);
35 }
36
37 return out.length > 0 ? out : undefined;
38}
39
40export function parseAgentId(value: unknown): string | undefined {
41 if (typeof value !== "string" || value.trim().length === 0) {

Callers 2

normalizeUserPreferencesFunction · 0.90

Calls 4

addMethod · 0.80
parseNonEmptyStringFunction · 0.70
pushMethod · 0.65
hasMethod · 0.45

Tested by

no test coverage detected