(obj: Record<string, unknown>)
| 24 | } |
| 25 | |
| 26 | function stripUndefinedValues(obj: Record<string, unknown>): Record<string, unknown> { |
| 27 | const result: Record<string, unknown> = {}; |
| 28 | for (const [key, value] of Object.entries(obj)) { |
| 29 | if (value === undefined) { |
| 30 | continue; |
| 31 | } |
| 32 | if (isObject(value)) { |
| 33 | const stripped = stripUndefinedValues(value); |
| 34 | if (Object.keys(stripped).length > 0) { |
| 35 | result[key] = stripped; |
| 36 | } |
| 37 | continue; |
| 38 | } |
| 39 | result[key] = value; |
| 40 | } |
| 41 | return result; |
| 42 | } |
| 43 | |
| 44 | export const selectJson = <TData>(data: ApiResponse<TData>) => data.json; |
| 45 |
no test coverage detected