Openstatus
www.openstatus.dev
1export function parseInputToProps(
2 json: unknown,
3 eventProps?: string[],
4): Record<string, unknown> {
5 if (typeof json !== "object" || json === null) return {};
6
7 if (!eventProps) return {};
8
9 return eventProps.reduce(
10 (acc, prop) => {
11 if (prop in json) {
12 acc[prop] = json[prop as keyof typeof json];
13 }
14 return acc;
15 },
16 {} as Record<string, unknown>,
17 );
18}