( obj: T, )
| 3 | import { OptionValidationError } from './validate-filter-options.utils.js'; |
| 4 | |
| 5 | export function filterKebabCaseKeys<T extends Record<string, unknown>>( |
| 6 | obj: T, |
| 7 | ): T { |
| 8 | return Object.entries(obj) |
| 9 | .filter(([key]) => !key.includes('-')) |
| 10 | .reduce( |
| 11 | (acc, [key, value]) => |
| 12 | typeof value === 'string' || |
| 13 | (typeof value === 'object' && Array.isArray(obj[key])) |
| 14 | ? { ...acc, [key]: value } |
| 15 | : typeof value === 'object' && !Array.isArray(value) && value != null |
| 16 | ? { |
| 17 | ...acc, |
| 18 | [key]: filterKebabCaseKeys(value as Record<string, unknown>), |
| 19 | } |
| 20 | : { ...acc, [key]: value }, |
| 21 | {}, |
| 22 | ) as T; |
| 23 | } |
| 24 | |
| 25 | // Log error and flush stdout to ensure all logs are printed |
| 26 | // before Yargs exits or rethrows the error. |
no outgoing calls
no test coverage detected