Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to merge into existing target object, just like Object.assign #261

Open
jihu opened this issue Nov 16, 2023 · 0 comments
Open

Comments

@jihu
Copy link

jihu commented Nov 16, 2023

My use case is that I already have an object, and I want to merge another object into it, without getting a new object. Just like Object.assign works. Maybe you could add a option for this, called 'treatFirstObjectAsTarget'.

Example:

const sourceObject = { a: 1, b: 2, c: 3 };
const targetObject = { x: 10, y: 20, z: 30 };
deepMerge(targetObject, sourceObject, { treatFirstObjectAsTarget: true });
console.info(targetObject); // Should print: { x: 10, y: 20, z: 30, a: 1, b: 2, c: 3 };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant