mirror of
https://github.com/ershisan99/flashcards-example-project.git
synced 2025-12-16 20:59:27 +00:00
10 lines
339 B
TypeScript
10 lines
339 B
TypeScript
type Valuable<T> = { [K in keyof T as T[K] extends null | undefined ? never : K]: T[K] }
|
|
|
|
export function getValuable<T extends {}, V = Valuable<T>>(obj: T): V {
|
|
return Object.fromEntries(
|
|
Object.entries(obj).filter(
|
|
([, v]) => !((typeof v === 'string' && !v.length) || v === null || typeof v === 'undefined')
|
|
)
|
|
) as V
|
|
}
|