MCPcopy Index your code
hub / github.com/callstack/agent-device / optionalEnum

Function optionalEnum

src/commands/command-input.ts:433–444  ·  view source on GitHub ↗
(
  record: Record<string, unknown>,
  key: string,
  values: T,
)

Source from the content-addressed store, hash-verified

431}
432
433export function optionalEnum<const T extends readonly string[]>(
434 record: Record<string, unknown>,
435 key: string,
436 values: T,
437): T[number] | undefined {
438 const value = record[key];
439 if (value === undefined) return undefined;
440 if (typeof value !== 'string' || !values.includes(value)) {
441 throw new Error(`Expected ${key} to be one of: ${values.join(', ')}.`);
442 }
443 return value;
444}
445
446export function commonToClientOptions(
447 input: CommonCommandInput,

Callers 4

waitInputToOptionsFunction · 0.90
enumFieldFunction · 0.70
readCommonInputFunction · 0.70
readDeviceTargetFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…