@twotwoba/vv-cli
Version:
Easily create Vite + React/Vue3 project with TailwindCSS and other useful libraries. Also support Chrome extension.
12 lines (11 loc) • 355 B
text/typescript
/**
* 过滤对象中的 null/undefined 值
*/
export const filterObjNull = <T extends Record<string, unknown>>(
obj: T
): Partial<T> | undefined => {
if (typeof obj !== 'object' || obj == null) return
return Object.fromEntries(
Object.entries(obj).filter(([_, value]) => value !== null && value !== undefined)
) as Partial<T>
}