overwrite-object

1.0.5 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i overwrite-object

Weekly Downloads

1,052

Version

1.0.5

License

none

Last publish

Collaborators

  • arpadhegedus