utils/index.js
function merge(source, target) {
    if (target == null) {
        return clone(source);
    }
    if (source == null) {
        return clone(target);
    }
    if (typeof source !== 'object' || typeof target !== 'object') {
        return clone(target);
    }
    const merge = (source, target) => {
        Object.keys(target).forEach(key => {
            if (source[key] == null) {
                source[key] = target[key];
            } else if (typeof source[key] === 'object') {
                if (typeof target[key] === 'object') {
                    merge(source[key], target[key]);
                } else {
                    source[key] = target[key];
                }
            } else {
                source[key] = target[key];
            }
        });

        return source;
    };

    return merge(clone(source), clone(target));
}
function merge(source, target) {
    if (target == null) {
        return clone(source);
    }
    if (source == null) {
        return clone(target);
    }
    if (typeof source !== 'object' || typeof target !== 'object') {
        return clone(target);
    }
    const merge = (source, target) => {
        Object.keys(target).forEach(key => {
            if (source[key] == null) {
                source[key] = target[key];
            } else if (typeof source[key] === 'object') {
                if (typeof target[key] === 'object') {
                    merge(source[key], target[key]);
                } else {
                    source[key] = target[key];
                }
            } else {
                source[key] = target[key];
            }
        });

        return source;
    };

    return merge(clone(source), clone(target));
}
function merge ( source , target ) { if ( target == null ) { return clone ( source ) ; } if ( source == null ) { return clone ( target ) ; } if ( typeof source !== 'object' || typeof target !== 'object' ) { return clone ( target ) ; } const merge = ( source , target ) => { Object . keys ( target ) . forEach ( key => { if ( source [ key ] == null ) { source [ key ] = target [ key ] ; } else if ( typeof source [ key ] === 'object' ) { if ( typeof target [ key ] === 'object' ) { merge ( source [ key ] , target [ key ] ) ; } else { source [ key ] = target [ key ] ; } } else { source [ key ] = target [ key ] ; } } ) ; return source ; } ; return merge ( clone ( source ) , clone ( target ) ) ; }
Make clones of two objects then merge the second one into the first one and returns the merged object

@param {any} source
@param {any} target
@returns {any}
Make clones of two objects then merge the second one into the first one and returns the merged object