# Utility functions  ## Shallow merge two or more objects, e.g. merge({a: 1, b: 2}, {a: 2}, {a: 3}) => {a: 3, b: 2}
486081
function merge() {
  return [].slice.call(arguments).reduce(function (merged, source) {
    for (var prop in source) {
      merged[prop] = source[prop];
    }
    return merged;
  }, {});
}
938136
function MergeRowsWithHeaders(obj1, obj2) {
  for(var p in obj2){
    if(obj1[p] instanceof Array && obj1[p] instanceof Array){
      obj1[p] = obj1[p].concat(obj2[p])
    } else {
      obj1[p] = obj2[p]
    }
  }
  return obj1;
}
216421
function merge(iterable /* ...iterbles */) {
    var map = anObject(this);
    var setter = aFunction(map.set);
    var i = 0;
    while (i < arguments.length) {
      iterate(arguments[i++], setter, map, true);
    }
    return map;
  }
201429
function mergeObjects(a, b) {
    var r = { };
    for (var k in a)
        r[k] = a[k];
    for (var k in b)
        r[k] = b[k];
    return r;
}
413053
function(input, shallow, output) {
    if (shallow && _.every(input, _.isArray)) {
      return concat.apply(output, input);
    }
    each(input, function(value) {
      if (_.isArray(value) || _.isArguments(value)) {
        shallow ? push.apply(output, value) : flatten(value, shallow, output);
      } else {
        output.push(value);
      }
    });
    return output;
  }
531616
def _merge_a_into_b_simple(self, a, b):
        
        for k, v in a.items():
            b[k] = v
        return b
529662
function mergeArrays (a, b) {
    // if target is array then add b to array otherwise return undefined
    // so normal _.merge will be performed
    return Array.isArray(a) ? a.concat(b) : undefined
}
1263790
function merge(objectA, objectB) {
	for (var attrName in objectB) {
		if (objectB.hasOwnProperty(attrName)) {
			if (objectA.hasOwnProperty(attrName) && objectA[attrName] instanceof Object && objectB.hasOwnProperty(attrName) && objectB[attrName] instanceof Object) {
				objectA[attrName] = merge(objectA[attrName], objectB[attrName]);
			}
			else {
				objectA[attrName] = objectB[attrName];
			}
		}
	}
	return objectA;
}
1283840
def merge(a, b):
    ""
    for key in b:
        if isinstance(a.get(key), dict) and isinstance(b.get(key), dict):
            merge(a[key], b[key])
        else:
            a[key] = b[key]
    return a
173977
function merge(target) {
  for (var _len = arguments.length, sources = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
    sources[_key - 1] = arguments[_key];
  }

  if (!sources.length) return target;
  var source = sources.shift();

  if ((0, _isObject2.default)(target) && (0, _isObject2.default)(source)) {
    for (var key in source) {
      if ((0, _isObject2.default)(source[key])) {
        if (!target[key]) Object.assign(target, _defineProperty({}, key, {}));
        merge(target[key], source[key]);
      } else {
        Object.assign(target, _defineProperty({}, key, source[key]));
      }
    }
  }

  return merge.apply(undefined, [target].concat(sources));
}
822174
def merge_recursive(obj_a, obj_b, level=False):
    '''
    
    '''
    return aggregate(obj_a, obj_b, level,
                     map_class=AggregatedMap,
                     sequence_class=AggregatedSequence)
496993
function merge (obj1, obj2) {
  var c = {},
    keys = Object.keys(obj2),
    i;

  for (i = 0; i !== keys.length; i++) {
    c[keys[i]] = obj2[keys[i]];
  }

  keys = Object.keys(obj1);
  for (i = 0; i !== keys.length; i++) {
    if (!c.hasOwnProperty(keys[i])) {
      c[keys[i]] = obj1[keys[i]];
    }
  }

  return c;
}
811051
function mergeObject(target, source) {
  // create a variable to hold the target object
  // so it can be changed if its not an object
  let targetObject = target;
  let sourceObject = source;

  if (!isObj(target)) {
    targetObject = {};
  }

  if (!isObj(source)) {
    sourceObject = {};
  }

  // get the object keys for the target and source objects
  const targetKeys = Object.keys(targetObject);
  const sourceKeys = Object.keys(sourceObject);

  // create a empty object for the result
  const result = {};

  // go through all the target keys
  targetKeys.forEach((key) => {
    // check if the source object contains the key
    if (sourceKeys.indexOf(key) !== -1) {
      // check if the target value is null if it is
      // set the result as the source value, this
      // should be fine because if the source value
      // is null it isn't overriding the target value
      // and if it isn't null it is overriding
      // as expected
      if (targetObject[key] === null) {
        result[key] = sourceObject[key];
      } else if (isObj(targetObject[key])) {
        // check if the source value is an object if
        // it is then we need to merge both objects and
        // set the result value to the merged object
        if (isObj(sourceObject[key])) {
          result[key] = mergeObject(targetObject[key], sourceObject[key]);
        } else {
          // if the source value isn't an object we can
          // simply override the value
          result[key] = sourceObject[key];
        }
      } else {
        // if the target value isn't an object we can
        // simply override the value
        result[key] = sourceObject[key];
      }
    } else {
      // if the source doesn't contain the key set the result
      // as the original from the target
      result[key] = targetObject[key];
    }
  });

  // go through all the source keys
  sourceKeys.forEach((key) => {
    // if the target doesn't contain the key
    // then the value is new and should be added
    // to the result object
    if (targetKeys.indexOf(key) === -1) {
      result[key] = sourceObject[key];
    }
  });

  return result;
}
1255213
function mergeRecursive(obj1, obj2) {
  if (!obj1 && obj2) {
    obj1 = {};
  }
  for (var key in obj2) {
    if (!obj2.hasOwnProperty(key)) {
      continue;
    }
    merge(obj1, obj2, key);
  }
  return obj1;
}
836109
function mergeRecursive(obj1, obj2) {
	"use strict";

	/*jshint forin:false */
	for (var p in obj2) {
		try {
			// Property in destination object set; update its value.
			if (obj2[p].constructor === Object) {
				obj1[p] = mergeRecursive(obj1[p], obj2[p]);
			} else {
				obj1[p] = obj2[p];
			}
		} catch(e) {
			// Property in destination object not set; create it and set its value.
			obj1[p] = obj2[p];
		}
	}

	return obj1;
}
377722
function shallowCopy (targetObj, srcObj) {
      each(srcObj, function (prop) {
        targetObj[prop] = srcObj[prop];
      });

      return targetObj;
    }
192367
function(k, v) {
            var type = objType(v),
                tarType = objType(target[k]);

            if (deep && (type == "array" || type == "object")) {
                target[k] = type == tarType && (tarType == "array" || tarType == "object") ? target[k] : type == "array" ? [] : {};

                //to merge recursively
                jsonQ.merge(deep, target[k], v);
            } else {
                target[k] = v;
            }
        }