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

    Keywords

    none

    Install

    npm i overwrite-object

    DownloadsWeekly Downloads

    450

    Version

    1.0.5

    License

    none

    Last publish

    Collaborators

    • arpadhegedus