Files
wehub-resource-sync 98e40dac97
CLI Smoke Test / smoke-test-linux (20) (push) Has been cancelled
CLI Smoke Test / smoke-test-linux (24) (push) Has been cancelled
CLI Smoke Test / smoke-test-windows (20) (push) Has been cancelled
CLI Smoke Test / smoke-test-windows (24) (push) Has been cancelled
Expo App TypeScript typecheck / typecheck (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:40:49 +08:00

10 lines
431 B
TypeScript

/**
* Merges two objects while ignoring undefined values from the second object.
* This is useful when you want to update an object but not override existing values with undefined.
*/
export function mergeObjects<T>(base: T & object, updates: Partial<T>): T {
const filtered = Object.fromEntries(
Object.entries(updates).filter(([_, value]) => value !== undefined)
);
return { ...base, ...filtered } as T;
}