Sha256: 98f4a9586bf92b2255a72f95014b668f988500e91648d73075099155064d8565

Contents?: true

Size: 1.01 KB

Versions: 69

Compression:

Stored size: 1.01 KB

Contents

var hasOwn = require('./hasOwn');
var deepClone = require('../lang/deepClone');
var isObject = require('../lang/isObject');

    /**
     * Deep merge objects.
     */
    function merge() {
        var i = 1,
            key, val, obj, target;

        // make sure we don't modify source element and it's properties
        // objects are passed by reference
        target = deepClone( arguments[0] );

        while (obj = arguments[i++]) {
            for (key in obj) {
                if ( ! hasOwn(obj, key) ) {
                    continue;
                }

                val = obj[key];

                if ( isObject(val) && isObject(target[key]) ){
                    // inception, deep merge objects
                    target[key] = merge(target[key], val);
                } else {
                    // make sure arrays, regexp, date, objects are cloned
                    target[key] = deepClone(val);
                }

            }
        }

        return target;
    }

    module.exports = merge;


Version data entries

69 entries across 69 versions & 2 rubygems

Version Path
trusty-festivity-extension-2.6.3 node_modules/bower/node_modules/mout/object/merge.js
trusty-festivity-extension-2.6.2 node_modules/bower/node_modules/mout/object/merge.js
trusty-festivity-extension-2.6.1 node_modules/bower/node_modules/mout/object/merge.js
trusty-festivity-extension-2.6 node_modules/bower/node_modules/mout/object/merge.js
trusty-festivity-extension-2.5.19 node_modules/bower/node_modules/mout/object/merge.js
trusty-festivity-extension-2.5.18 node_modules/bower/node_modules/mout/object/merge.js
trusty-festivity-extension-2.5.17 node_modules/bower/node_modules/mout/object/merge.js
trusty-festivity-extension-2.5.16 node_modules/bower/node_modules/mout/object/merge.js
trusty-festivity-extension-2.5.15 node_modules/bower/node_modules/mout/object/merge.js
trusty-festivity-extension-2.5.14 node_modules/bower/node_modules/mout/object/merge.js
trusty-festivity-extension-2.5.13 node_modules/bower/node_modules/mout/object/merge.js
trusty-festivity-extension-2.5.12 node_modules/bower/node_modules/mout/object/merge.js
trusty-festivity-extension-2.5.11 node_modules/bower/node_modules/mout/object/merge.js
trusty-festivity-extension-2.5.10 node_modules/bower/node_modules/mout/object/merge.js
trusty-festivity-extension-2.5.9 node_modules/bower/node_modules/mout/object/merge.js
trusty-festivity-extension-2.5.8 node_modules/bower/node_modules/mout/object/merge.js
trusty-festivity-extension-2.5.7 node_modules/bower/node_modules/mout/object/merge.js
trusty-festivity-extension-2.5.6 node_modules/bower/node_modules/mout/object/merge.js
trusty-festivity-extension-2.5.5 node_modules/bower/node_modules/mout/object/merge.js
trusty-festivity-extension-2.5.4 node_modules/bower/node_modules/mout/object/merge.js