export function filter_object< ObjectType, Key extends keyof ObjectType, Value extends ObjectType[keyof ObjectType] >( obj: ObjectType, filter_cb: (key: Key, value: Value) => boolean ) { const entries = Object.entries(obj); const filtered = entries.filter(([ str_key, any_value ]) => { return filter_cb(str_key as Key, any_value as Value); }); return Object.fromEntries(filtered) as ObjectType; }