Deep merge two objects.

@param target
@param source
763539
function mergeDeep (target, source) {
  let dummy;

  if (isObject(target) && isObject(source)) {
    for (const key in source) {
      if (isObject(source[key])) {
        if (!target[key]) {
          dummy = {};
          dummy[key] = {};
          objectAssign(target, dummy);
        }
        mergeDeep(target[key], source[key]);
      } else {
        dummy = {};
        dummy[key] = source[key];
        objectAssign(target, dummy);
      }
    }
  }
  return target;
}
783930
function copyMerged(source, target) {
    for (var
      key, descriptor, value, tvalue,
      names = oK(source),
      i = 0; i < names.length; i++
    ) {
      key = names[i];
      descriptor = gOPD(source, key);
      // target already has this property
      if (hOP.call(target, key)) {
        // verify the descriptor can  be merged
        if (hOP.call(descriptor, VALUE)) {
          value = descriptor[VALUE];
          // which means, verify it's an object
          if (isObject(value)) {
            // in such case, verify the target can be modified
            descriptor = gOPD(target, key);
            // meaning verify it's a data descriptor
            if (hOP.call(descriptor, VALUE)) {
              tvalue = descriptor[VALUE];
              // and it's actually an object
              if (isObject(tvalue)) {
                copyMerged(value, tvalue);
              }
            }
          }
        }
      } else {
        // target has no property at all
        if (hOP.call(descriptor, VALUE)) {
          // copy deep if it's an object
          copyValueIfObject(descriptor, copyDeep);
        }
        defineProperty(target, key, descriptor);
      }
    }
  }
1039413
public static void copyPropertiesToMap(Properties source,Map<String,String> target)
    {
        if(source!=null)
        {
            //convert to map
            Iterator<Entry<Object,Object>> iterator=source.entrySet().iterator();
            Entry<Object,Object> entry=null;
            String key=null;
            String value=null;
            while(iterator.hasNext())
            {
                //get next entry
                entry=iterator.next();
                
                //get next key/value
                key=(String)entry.getKey();
                value=(String)entry.getValue();
                
                //put in map
                target.put(key,value);
            }
        }
    }
1170630
function(target, source, all) {
        target = target || {};
        for (var key in source) {
            // merge only if hasOwnProperty unless `all´ flag is set
            if (all || source.hasOwnProperty(key)) {
                target[key] = source[key];
            }
        }
        return target;
    }
1040524
public static void copyDirectory(File source, File target) {
        if (source.isDirectory()) {
            if (!target.exists()) {
                target.mkdir();
            }
            for (String child : source.list()) {
                copyDirectory(new File(source, child), new File(target, child));
            }
        } else {
            try {
                write(new FileInputStream(source), new FileOutputStream(target));
            } catch (IOException e) {
                if (target.isDirectory()) {
                    if (!target.exists()) {
                        if (!target.mkdirs()) {
                            throw E.ioException("cannot copy [%s] to [%s]", source, target);
                        }
                    }
                    target = new File(target, source.getName());
                } else {
                    File targetFolder = target.getParentFile();
                    if (!targetFolder.exists()) {
                        if (!targetFolder.mkdirs()) {
                            throw E.ioException("cannot copy [%s] to [%s]", source, target);
                        }
                    }
                }
                try {
                    write(new FileInputStream(source), new FileOutputStream(target));
                } catch (IOException e0) {
                    throw E.ioException(e0);
                }
            }
        }
    }
74520
def merge_specs(target, source):
    

    for key, value in source.items():
        if isinstance(value, dict):
            node = target.setdefault(key, {})
            merge_specs(node, value)
        elif isinstance(value, list):
            node = target.setdefault(key, [])
            node.extend(value)
        else:
            target[key] = value
209101
public static void merge(List<String> sources, String target) throws IOException{
        //读取所有需要合并的词典
        Set<String> set = new HashSet<>();
        AtomicInteger i = new AtomicInteger();
        for(String source : sources){
            try(Stream<String> lines = Files.lines(Paths.get(source), Charset.forName("utf-8"))){
                lines.forEach(line -> {
                    i.incrementAndGet();
                    line = line.trim();
                    // 词长度：大于等于2并且小于等于4
                    // 识别功能 能识别的词 就不用放到词典中了，没必要多此一举
                    //至少要两个中文字符，防止大量无意义或特殊词混入词典
                    if (line.length() > 4
                            || line.length() < 2
                            || !Utils.isChineseCharAndLengthAtLeastTwo(line)
                            || RecognitionTool.recog(line)) {
                        LOGGER.debug("过滤：" + line);
                        return;
                    }
                    set.add(line);
                });
            }
        }
        LOGGER.info("合并词数："+i.get());
        LOGGER.info("保留词数："+set.size());
        List<String> list = set.stream().sorted().collect(Collectors.toList());
        Files.write(Paths.get(target), list, Charset.forName("utf-8"));
    }
839299
protected static function mergeObjects(stdClass &$target, stdClass ...$sources): void
    {
        foreach ($sources as $source) {
            foreach ($source as $key => $value) {
                if (str_starts_with($key, 'i__')) {
                    continue;
                }

                if (isset($target->$key) && is_object($value) && is_object($target->$key)) {
                    static::mergeObjects($target->$key, $value);
                } else {
                    $target->$key = $value;
                }
            }
        }
    }
449069
public static void copyProperties(Object source, Object target) {
		copyProperties(source, target, CopyOptions.create());
	}
712079
private AdvancedModelWrapper performMerge(AdvancedModelWrapper source, AdvancedModelWrapper target) {
        if (source == null || target == null) {
            return null;
        }
        ModelDescription sourceDesc = source.getModelDescription();
        ModelDescription targetDesc = target.getModelDescription();
        Object transformResult = transformationEngine.performTransformation(sourceDesc, targetDesc,
            source.getUnderlyingModel(), target.getUnderlyingModel());
        AdvancedModelWrapper wrapper = AdvancedModelWrapper.wrap(transformResult);
        wrapper.removeOpenEngSBModelEntry(EDBConstants.MODEL_VERSION);
        return wrapper;
    }
966302
@Override
    public T merge(Archive<?> source, Filter<ArchivePath> filter) throws IllegalArgumentException {
        return merge(source, new BasicPath(), filter);
    }
1350923
private void updateProperties(T target, Map<String, Object> source) {
        Map<String, PropertyDescriptor> mapTargetProps = MappingUtils.mapPropertyDescriptors(target.getClass());

        for (String sourceKey : source.keySet()) {
            if (mapTargetProps.containsKey(sourceKey) == true) {
                MappingUtils.callSetter(target, mapTargetProps.get(sourceKey), source.get(sourceKey));
            }
        }
    }
264309
private void updateObjectFields(BioPAXElement source, Model target)
	{
		//Skip if target model had a different object with the same URI as the source's,
		//and no Filter was set (mergePropOf is null); i.e., when
		//we simply want the source to be replaced with the object
		//having the same type and URI and that's already present in the target model.
		BioPAXElement keep = target.getByID(source.getUri());
		if(keep != source && mergePropOf ==null)
		{
			return; //nothing to do
		}
		
		Set<PropertyEditor> editors = map.getEditorsOf(source);
		for (PropertyEditor editor : editors)
		{
			if (editor instanceof ObjectPropertyEditor)
			{
				//copy prop. values (to avoid concurrent modification exception)
				Set<BioPAXElement> values = new HashSet<BioPAXElement>((Set<BioPAXElement>) editor.getValueFromBean(source));
				if(keep == source) //i.e., it has been just added to the target, - simply update properties
				{
					for (BioPAXElement value : values) {
						migrateToTarget(source, target, editor, value);
					}
				} else //source is normally to be entirely replaced, but if it passes the filter,
					if(mergePropOf !=null && mergePropOf.filter(source)
						&& editor.isMultipleCardinality()) // and the prop. is multi-cardinality,
				{
					// - then we want to copy some values
					for (BioPAXElement value : values) {
						mergeToTarget(keep, target, editor, value);
					}
				}

			}
			else // - primitive, enum, or string property editor (e.g., comment, name), and -
				if (mergePropOf != null && mergePropOf.filter(source) && editor.isMultipleCardinality())
			{
				Set<Object> values = new HashSet<Object>((Set<Object>) editor.getValueFromBean(source));
				for (Object value : values) {
					mergeToTarget(keep, target, editor, value);
				}
			}
		}
	}
843742
function merge(source, destination) {
  source.forEach(function(current) {
    let matchFound = false;
    destination.forEach(function(target) {
      let isSameReceiver = identifiers.areMatch(current.receiverId,
                                                current.receiverIdType,
                                                target.receiverId,
                                                target.receiverIdType);
      if(isSameReceiver) {
        target.rssiSum = target.rssiSum ||
                         (target.rssi * target.numberOfDecodings);
        target.numberOfDecodings += current.numberOfDecodings || 1;
        target.rssiSum += current.rssiSum ||
                          (current.rssi * current.numberOfDecodings);
        target.rssi = Math.round(target.rssiSum / target.numberOfDecodings);
        matchFound = true;
      }
    });
    if(!matchFound) {
      destination.push(current);
    }
  });
  destination.sort(compareRssi);
}
166613
function(target,source) {
    var keys = Object.keys(source);
    var len = keys.length;
    for (var i = 0; i < len; i++) {
      var key = keys[i];
      if (lib.type.isObject(source[key])) {
        if (!lib.type.isObject(target[key])) {
          target[key] = {};
        }
        factory.merge(target[key],source[key]);
      } else {
        target[key] = source[key];
      }
    }
    return target;
  }
791546
function merge() {
  let i = 1
    , key
    , val
    , obj
    , target
    ;

  // make sure we don't modify source element and it's properties
  // objects are passed by reference
  target = clone( 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 {
        let is_url = val && val.type == url;
        let is_path = val && val.type == path;

        // make sure arrays, regexp, date, objects are cloned
        target[key] = clone(val);
        if( is_url ){
          target[key].type = url;
        }

        if( is_path ){
          target[key].type = path;
        }
      }
    }
  }
  return target;
}
113746
private static final <E> void moveAll(ArrayList<E> source, ArrayList<E> target) {
		target.ensureCapacity(target.size() + source.size());
		for (int i = source.size() - 1; i >= 0; i--) {
			target.add(source.remove(i));
		}
	}