overwrite-object
v1.0.5
Published
A tiny module to merge two objects and overwrite values cleverly.
Downloads
3,023
Readme
#overwrite-object
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'
]
};