src/editor.js
function _mergeObjs() {
    // copy reference to target object
    var target = arguments[0] || {}
      , i = 1
      , length = arguments.length
      , deep = false
      , options
      , name
      , src
      , copy

    // Handle a deep copy situation
    if (typeof target === "boolean") {
      deep = target;
      target = arguments[1] || {};
      // skip the boolean and the target
      i = 2;
    }

    // Handle case when target is a string or something (possible in deep copy)
    if (typeof target !== "object" && !_isFunction(target)) {
      target = {};
    }
    // extend jQuery itself if only one argument is passed
    if (length === i) {
      target = this;
      --i;
    }

    for (; i < length; i++) {
      // Only deal with non-null/undefined values
      if ((options = arguments[i]) != null) {
        // Extend the base object
        for (name in options) {
          // @NOTE: added hasOwnProperty check
          if (options.hasOwnProperty(name)) {
            src = target[name];
            copy = options[name];
            // Prevent never-ending loop
            if (target === copy) {
              continue;
            }
            // Recurse if we're merging object values
            if (deep && copy && typeof copy === "object" && !copy.nodeType) {
              target[name] = _mergeObjs(deep,
                // Never move original objects, clone them
                src || (copy.length != null ? [] : {})
                , copy);
            } else if (copy !== undefined) { // Don't bring in undefined values
              target[name] = copy;
            }
          }
        }
      }
    }

    // Return the modified object
    return target;
  }
function _mergeObjs() {
    // copy reference to target object
    var target = arguments[0] || {}
      , i = 1
      , length = arguments.length
      , deep = false
      , options
      , name
      , src
      , copy

    // Handle a deep copy situation
    if (typeof target === "boolean") {
      deep = target;
      target = arguments[1] || {};
      // skip the boolean and the target
      i = 2;
    }

    // Handle case when target is a string or something (possible in deep copy)
    if (typeof target !== "object" && !_isFunction(target)) {
      target = {};
    }
    // extend jQuery itself if only one argument is passed
    if (length === i) {
      target = this;
      --i;
    }

    for (; i < length; i++) {
      // Only deal with non-null/undefined values
      if ((options = arguments[i]) != null) {
        // Extend the base object
        for (name in options) {
          // @NOTE: added hasOwnProperty check
          if (options.hasOwnProperty(name)) {
            src = target[name];
            copy = options[name];
            // Prevent never-ending loop
            if (target === copy) {
              continue;
            }
            // Recurse if we're merging object values
            if (deep && copy && typeof copy === "object" && !copy.nodeType) {
              target[name] = _mergeObjs(deep,
                // Never move original objects, clone them
                src || (copy.length != null ? [] : {})
                , copy);
            } else if (copy !== undefined) { // Don't bring in undefined values
              target[name] = copy;
            }
          }
        }
      }
    }

    // Return the modified object
    return target;
  }
function _mergeObjs ( ) { // copy reference to target object var target = arguments [ 0 ] || { } , i = 1 , length = arguments . length , deep = false , options , name , src , copy // Handle a deep copy situation if ( typeof target === "boolean" ) { deep = target ; target = arguments [ 1 ] || { } ; // skip the boolean and the target i = 2 ; } // Handle case when target is a string or something (possible in deep copy) if ( typeof target !== "object" && ! _isFunction ( target ) ) { target = { } ; } // extend jQuery itself if only one argument is passed if ( length === i ) { target = this ; -- i ; } for ( ; i < length ; i ++ ) { // Only deal with non-null/undefined values if ( ( options = arguments [ i ] ) != null ) { // Extend the base object for ( name in options ) { // @NOTE: added hasOwnProperty check if ( options . hasOwnProperty ( name ) ) { src = target [ name ] ; copy = options [ name ] ; // Prevent never-ending loop if ( target === copy ) { continue ; } // Recurse if we're merging object values if ( deep && copy && typeof copy === "object" && ! copy . nodeType ) { target [ name ] = _mergeObjs ( deep , // Never move original objects, clone them src || ( copy . length != null ? [ ] : { } ) , copy ) ; } else if ( copy !== undefined ) { // Don't bring in undefined values target [ name ] = copy ; } } } } } // Return the modified object return target ; }
Overwrites obj1's values with obj2's and adds obj2's if non existent in obj1
@param {boolean} [deepMerge=false] If true, will deep merge meaning it will merge sub-objects like {obj:obj2{foo:'bar'}}
@param {object} first object
@param {object} second object
@returnss {object} a new object based on obj1 and obj2
Overwrites obj1 s values with obj2 s and adds obj2 s if non existent in obj1