MCPcopy Index your code
hub / github.com/simstudioai/sim / parseUsernames

Function parseUsernames

apps/sim/connectors/x/x.ts:109–119  ·  view source on GitHub ↗

* Parses the configured usernames into a normalized, deduplicated handle list. * * Handles are lowercased and stripped of a leading `@` before deduplication so * that `jack`, `@jack`, and `Jack` collapse to a single entry — avoiding a * duplicate user-id lookup and a redundant `userIndex` slot i

(value: unknown)

Source from the content-addressed store, hash-verified

107 * cursor's `userIndex` stays aligned to the same array across pages.
108 */
109function parseUsernames(value: unknown): string[] {
110 const seen = new Set<string>()
111 const out: string[] = []
112 for (const raw of parseMultiValue(value)) {
113 const handle = raw.replace(/^@/, '').toLowerCase()
114 if (!handle || seen.has(handle)) continue
115 seen.add(handle)
116 out.push(handle)
117 }
118 return out
119}
120
121/**
122 * Reads and trims a string config field, returning undefined when blank.

Callers 1

x.tsFile · 0.85

Calls 4

parseMultiValueFunction · 0.90
replaceMethod · 0.65
addMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected