quivr/frontend/lib/helpers/removeUndefined.ts

13 lines
253 B
TypeScript
Raw Normal View History

export const removeUndefined = <T extends Record<string, unknown>>(
obj: T
): Partial<T> => {
const newObj = {} as Partial<T>;
for (const key in obj) {
if (obj[key] !== undefined) {
newObj[key] = obj[key];
}
}
return newObj;
};