Skip to content

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

@jihu

Description

@jihu

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 };

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions