(
obj: Readonly<{ [key: string]: T }>,
predicate: (key: string, value: T) => boolean,
)
| 80 | * Filters the object to the key-value pairs where the predicate returns true. |
| 81 | */ |
| 82 | export function filterObject<T>( |
| 83 | obj: Readonly<{ [key: string]: T }>, |
| 84 | predicate: (key: string, value: T) => boolean, |
| 85 | ): { [key: string]: T } { |
| 86 | const next: { [key: string]: T } = {}; |
| 87 | for (const key of Object.keys(obj)) { |
| 88 | if (predicate(key, obj[key])) { |
| 89 | next[key] = obj[key]; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | return next; |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Sorts the object keys using the given sorting function. |
no test coverage detected