Files
payload/packages/ui/src/utilities/removeUndefined.ts
Jacob Fletcher 2d7626c3e9 perf: removes undefined props from rsc requests (#9195)
This is in effort to reduce overall HTML bloat, undefined props still go
through the request as `$undefined` and must be explicitly omitted.
2024-11-14 18:22:42 +00:00

4 lines
162 B
TypeScript

export function removeUndefined<T extends object>(obj: T): T {
return Object.fromEntries(Object.entries(obj).filter(([, value]) => value !== undefined)) as T
}