Skip to content

A tiny module to merge two objects and overwrite values cleverly

License

Notifications You must be signed in to change notification settings

arpadHegedus/overwrite-object

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A tiny module to merge two objects and overwrite values cleverly.

Installation

npm install overwrite-object

Example

var overwriteObject = require('overwrite-object');

var obj1 = {
    name: {
        first: 'John',
        last: 'Smith'
    },
    age: 30,
    hobbies: [
        'mountain climbing', 'pets'
    ]
};
var obj2 = {
    name: {
        title: 'Mr'
    },
    age: 'N.A.',
    hobbies: [
        'eating out', 'long walks in the park'
    ]
};

var newObj = overwriteObject(obj1, obj2);

will produce

var newObj = {
    name: {
        first: 'John',
        last: 'Smith',
        title: 'Mr'
    },
    age: 'N.A.',
    hobbies: [
        'mountain climbing', 'pets', 'eating out', 'long walks in the park'
    ]
};

About

A tiny module to merge two objects and overwrite values cleverly

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages