/*!
Start merge scenario for arrays.

@param {Array} destination
@param {Array} source
@return {Array} destination merged
@api private
760565
function mergeArray(a, b) {
  var adds = [];
  var ai = 0;

  for (var i = 0; i < b.length; i++) {
    if (('object' === type(a[i]) && 'object' === type(b[i]))
    ||  ('array' === type(a[i]) && 'array' === type(b[i]))) {
      a[i] = merge(a[i], b[i]);
    } else if ('object' === type(b[i])) {
      adds.push(merge({}, b[i]));
    } else if ('array' === type(b[i])) {
      adds.push(merge([], b[i]));
    } else if (!~a.indexOf(b[i])) {
      adds.push(b[i]);
    }
  }

  for (; ai < adds.length; ai++) {
    a.push(adds[ai]);
  }

  return a;
}
340363
public static <D,S> IJMapper<D, S> getMapper(final Class<D> destination, final Class<S> source){
		return getMapper(destination,source, undefinedConfig());
	}
954362
function doMerge(source, target, opts) {
  return target instanceof Array
    ? mergeArrays(source, target)
    : mergeObjects(source, target, opts)
}
979682
function deepCopy(destination, source) {
    Object.keys(source).forEach(function (property) {
        if (destination[property] && isObject(destination[property])) {
            deepCopy(destination[property], source[property]);
        } else {
            destination[property] = source[property];
        }
    });
}
1069755
function() {
        var obj = arguments[0], args = Array.prototype.slice.call(arguments, 1);

        function copy(destination, source) {
            for (var property in source) {
                if (source[property] && source[property].constructor &&
                    source[property].constructor === Object) {
                    destination[property] = destination[property] || {};
                    copy(destination[property], source[property]);
                } else {
                    destination[property] = source[property];
                }
            }
            return destination;
        }

        for(var i in args) {
            copy(obj, args[i]);
        }

        return obj;
    }
1110458
function _merge (getKeys, a, b) {
    return reduce([a, b], function (result, source) {
        forEach(getKeys(source), function (key) {
            result[key] = source[key];
        });

        return result;
    }, {});
}
1169935
private void mergeMappings(TypeMap<?, ?> destinationMap) {
    for (Mapping mapping : destinationMap.getMappings()) {
      InternalMapping internalMapping = (InternalMapping) mapping;
      mergedMappings.add(internalMapping.createMergedCopy(
          propertyNameInfo.getSourceProperties(), propertyNameInfo.getDestinationProperties()));
    }
  }
953964
function extend(destination, source, deepCopy) {
    if (Type.isUndefined(source)) {
        return extend({}, destination, false);
    }
    if (Type.isObject(destination) && Type.isObject(source) && !Type.isArray(source) && !Type.isArray(destination)) {
        Object.keys(source).forEach(function (key) {
            destination[key] = Type.assert(Type.BOOLEAN, deepCopy) && !!deepCopy ? copy(source[key]) : source[key];
        });
    } else {
        throw new Error('Core.extend:  invalid source or destination type:');
    }
    return destination;
}
948362
function mergePathMaps(sourceMaps, targetMap, targetDir) {
    // Merge multiple source maps together, along with target path info.
    // Entries in later source maps override those in earlier source maps.
    // Target stats will be filled in below for targets that exist.
    var pathMap = {};
    sourceMaps.forEach(function (sourceMap) {
        Object.keys(sourceMap).forEach(function(sourceSubPath){
            var sourceEntry = sourceMap[sourceSubPath];
            pathMap[sourceSubPath] = {
                targetPath: path.join(targetDir, sourceSubPath),
                targetStats: null,
                sourcePath: path.join(sourceEntry.subDir, sourceSubPath),
                sourceStats: sourceEntry.stats
            };
        });
    });

    // Fill in target stats for targets that exist, and create entries
    // for targets that don't have any corresponding sources.
    Object.keys(targetMap).forEach(function(subPath){
        var entry = pathMap[subPath];
        if (entry) {
            entry.targetStats = targetMap[subPath].stats;
        } else {
            pathMap[subPath] = {
                targetPath: path.join(targetDir, subPath),
                targetStats: targetMap[subPath].stats,
                sourcePath: null,
                sourceStats: null
            };
        }
    });

    return pathMap;
}
828494
function copyProperties (source, destination) {
  var props = Object.getOwnPropertyNames(source);
  props.forEach(function (prop) {
    var desc;
    if (!destination[prop]) {
      desc = Object.getOwnPropertyDescriptor(source, prop);
      destination[prop] = {value: source[prop], writable: desc.writable};
    }
  });
}
940116
function _merge (opts, target, source) {
  var i
  var j
  var tmp
  var test
  var equal
  var key
  var s = { // hold booleans for source
    isObj: util.isObject(source),
    isFn: util.isFunction(source),
    isArr: util.isArray(source)
  }
  var t = { // hold booleans for target
    isObj: util.isObject(target),
    isFn: util.isFunction(target),
    isArr: util.isArray(target)
  }

  if (!opts._visited) {
    opts._visited = []
  }

  if (target === source || // for primitives or null
    undefined === source // target stays the same
  ) {
    return target
  }

  if (source === null) {
    if (!opts.ignoreNull || target === undefined) {
      target = source
    }
    return target
  }

  if (target === null || undefined === target) {
    if (s.isObj && s.isArr) {
      // clone into array
      target = _merge(opts, [], source)
    } else if (s.isObj) {
      // clone source
      target = _merge(opts, {}, source)
    } else {
      // copy primitives
      target = source
    }
    return target
  }

  // create new instances for "special" objects
  if (s.isObj) {
    if (util.isRegExp(source)) {
      // create new RegExp
      target = new RegExp(source)
      return target
    } else if (util.isDate(source)) {
      // create new Date
      target = new Date(source)
      return target
    } else if (util.isBuffer(source)) {
      // create new Buffer
      target = new Buffer(source)
      return target
    }
  }

  if (s.isFn) { // replace with source function
    target = source
    // TODO - clone possible keys
    return target
  }

  if (s.isArr) {
    if (t.isArr) {
      test = [].concat(target) // test for duplicates
      for (i = 0; i < source.length; i++) {
        tmp = source[i]
        if (!~test.indexOf(tmp)) {
          if (!util.isObject(tmp) || tmp === null) { // primitive or function or null or undefined
            target.push(tmp)
          } else {
            equal = false
            j = test.length
            while (j-- > 0 && !(equal = deepEqual(test[j], tmp)));
            if (!equal) target.push(_merge(opts, null, tmp))
          }
        }
      }
    } else {
      // if target is not array replace with source
      target = _merge(opts, [], source)
    }
    return target
  }

  if (!t.isFn && !t.isObj && !t.isArr) {
    // copy primitives
    target = source
    return target
  }

  // copy properties if not circular
  if (!~opts._visited.indexOf(source)) {
    opts._visited.push(source)
    for (key in source) {
      if (source.hasOwnProperty(key) && key !== '__proto__') {
        target[key] = _merge(opts, target[key], source[key])
      }
    }
    opts._visited.pop()
  } else if (!opts.ignoreCircular) {
    throw new Error('can not merge circular structures.')
  }

  return target
}
982685
function mergeArrays(source, target) {
  for (let i = 0; i < source.length; i++) {
    // If the item is not yet in the target array, add it
    if (target.indexOf(source[i]) === -1) {
      target.push(source[i])
    }
  }

  return target
}
1373870
private function makeArrayFromOptionsAndValues(array $source, array &$destination): array
    {
        $destination = [];

        foreach ($source as $value) {
            list($k, $v) = explode("=", $value);
            $destination[trim($k, "- ")] = trim($v);
        }

        return $destination;
    }
517826
async function loadSources (sources, options) {
  const mergedConfig = {};

  function handleSourceLoad (sourceConfig) {
    if (sourceConfig) merge(sourceConfig, mergedConfig);
  }

  for (const source of sources) {
    let sourceConfig;

    if (source == null) {
            // No-op... skip this source
      continue;
    } else if (typeof source === 'string') {
            // Load a source from a JSON file
      sourceConfig = await loadFileSource(source, options);
    } else if (Array.isArray(source)) {
      sourceConfig = await loadSources(source, options); // Load and merge all of the sources
    } else if (typeof source === 'function') {
      sourceConfig = await source(); // Invoke the function to asynchronously load the config object for this source
    } else if (typeof source === 'object') {
      sourceConfig = source; // Just merge the object
    } else {
      throw new Error('Invalid configuration source: ' + source);
    }

    handleSourceLoad(sourceConfig);
  }

  return mergedConfig;
}
968930
function merge (target, src) {
        var dst = {};

        if (target && typeof target === 'object') {
            Object.keys(target).forEach(function (key) {
                dst[key] = target[key];
            });
        }
        Object.keys(src).forEach(function (key) {
            if (typeof src[key] !== 'object' || !src[key]) {
                dst[key] = src[key];
            } else {
                if (!target[key]) {
                    dst[key] = src[key];
                } else {
                    dst[key] = merge(target[key], src[key]);
                }
            }
        });

        return dst;
    }
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
}
139858
function merge( to ){
	var from,
		i, c,
		m = function( val, key ){
			to[ key ] = merge( to[key], val );
		};

	for( i = 1, c = arguments.length; i < c; i++ ){
		from = arguments[i];

		if ( to === from ){
			continue;
		}else if ( to && to.merge ){
			to.merge( from );
		}else if ( !bmoor.isObject(from) ){
			to = from;
		}else if ( !bmoor.isObject(to) ){
			to = merge( {}, from );
		}else{
			bmoor.safe( from, m );
		}
	}
	
	return to;
}