MCPcopy
hub / github.com/callstack/agent-device / readRequired

Function readRequired

src/utils/parsing.ts:5–16  ·  view source on GitHub ↗
(
  record: Record<string, unknown>,
  key: string,
  parse: (value: unknown) => T | undefined,
  message: string,
)

Source from the content-addressed store, hash-verified

3import type { Point, Rect } from '../kernel/snapshot.ts';
4
5function readRequired<T>(
6 record: Record<string, unknown>,
7 key: string,
8 parse: (value: unknown) => T | undefined,
9 message: string,
10): T {
11 const value = parse(record[key]);
12 if (value === undefined) {
13 throw new AppError('COMMAND_FAILED', message, { response: record });
14 }
15 return value;
16}
17
18function readOptional<T>(
19 record: Record<string, unknown>,

Callers 4

readRequiredStringFunction · 0.85
readRequiredNumberFunction · 0.85
readRequiredPlatformFunction · 0.85
readRequiredDeviceKindFunction · 0.85

Calls 1

parseFunction · 0.70

Tested by

no test coverage detected