1.0.5 • Published 7 years ago

overwrite-object v1.0.5

Weekly downloads
355
License
-
Repository
github
Last release
7 years ago

#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'
    ]
};
1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago