( record: Record<string, unknown>, key: string, parse: (value: unknown) => T | undefined, message: string, )
| 3 | import type { Point, Rect } from '../kernel/snapshot.ts'; |
| 4 | |
| 5 | function 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 | |
| 18 | function readOptional<T>( |
| 19 | record: Record<string, unknown>, |
no test coverage detected