Recursively merge the given config objects as the root options by handling
default scale options for the `scales` and `scale` properties, then returns
a deep copy of the result, thus doesn't alter inputs.
170701
function mergeConfig(/* config objects ... */) {
	return helpers$1.merge({}, [].slice.call(arguments), {
		merger: function(key, target, source, options) {
			var tval = target[key] || {};
			var sval = source[key];

			if (key === 'scales') {
				// scale config merging is complex. Add our own function here for that
				target[key] = mergeScaleConfig(tval, sval);
			} else if (key === 'scale') {
				// used in polar area & radar charts since there is only one scale
				target[key] = helpers$1.merge(tval, [core_scaleService.getScaleDefaults(sval.type), sval]);
			} else {
				helpers$1._merger(key, target, source, options);
			}
		}
	});
}
1061185
def merge(a, b):
    
    if isinstance(a, CONFIG_VALID) \
            and isinstance(b, CONFIG_VALID):
        # dict update
        if isinstance(a, dict) and isinstance(b, dict):
            a.update(b)
            return a
        # list update
        _a = list(a)
        for x in list(b):
            if x not in _a:
                _a.append(x)
        return _a
    if a and b:
        raise Exception("Cannot merge")
    raise NotImplementedError
684020
function deepMerge (base, custom) {
  Object.keys(custom).forEach(function (key) {
    if (!base.hasOwnProperty(key) || typeof base[key] !== 'object') {
      base[key] = custom[key]
    } else {
      base[key] = deepMerge(base[key], custom[key])
    }
  })

  return base
}
853881
function merge(target, options) {
  var key;
  if (!target) { target = {}; }
  if (options) {
    for (key in options) {
      if (options.hasOwnProperty(key)) {
        var targetHasIt = target.hasOwnProperty(key),
            optionsValueType = typeof options[key],
            shouldReplace = !targetHasIt || (typeof target[key] !== optionsValueType);

        if (shouldReplace) {
          target[key] = options[key];
        } else if (optionsValueType === 'object') {
          // go deep, don't care about loops here, we are simple API!:
          target[key] = merge(target[key], options[key]);
        }
      }
    }
  }

  return target;
}
230950
function merge_config(top_config, base_config)
{
    for (var option in top_config)
    {
        if (Array.isArray(top_config[option])) // handle array elements in the same order
        {
            if (!Array.isArray(base_config[option]))
                base_config[option] = top_config[option];
            else
            {
                for(var i=0;i<top_config[option].length;i++)
                {
                    if (base_config[option].length <= i)
                        base_config[option].push(top_config[option][i]);
                    else
                        merge_config(top_config[option][i],base_config[option][i]);
                }
            } 
        }
        else if (typeof top_config[option] === "Object") // recurseively handle complex configurations
        {
            if (base_config[option] === undefined)
                base_config[option] = top_config[option];
            else
                merge_config(top_config[option], base_config[option]);
        }
        else
            base_config[option] = top_config[option];
    }

}
1369375
def merge_configs(default, overwrite):
    
    new_config = copy.deepcopy(default)

    for k, v in overwrite.items():
        # Make sure to preserve existing items in
        # nested dicts, for example `abbreviations`
        if isinstance(v, dict):
            new_config[k] = merge_configs(default[k], v)
        else:
            new_config[k] = v

    return new_config
192335
function mergeOptions(base, custom) {
  return Object.assign({}, defaultOptions, base, custom, {
    open: Object.assign({}, defaultOptions.open, base.open, custom.open),
    send: Object.assign({}, defaultOptions.send, base.send, custom.send),
  })
}
992136
def _recursive_merge(dct, merge_dct, raise_on_missing):
    # type: (Dict[str, Any], Dict[str, Any], bool) -> Dict[str, Any]
    
    for k, v in merge_dct.items():
        if k in dct:
            if isinstance(dct[k], dict) and isinstance(merge_dct[k], BaseMapping):
                dct[k] = _recursive_merge(dct[k], merge_dct[k], raise_on_missing)
            else:
                dct[k] = merge_dct[k]
        elif isinstance(dct, Extensible):
            dct[k] = merge_dct[k]
        else:
            message = "Unknown configuration key: '{k}'".format(k=k)
            if raise_on_missing:
                raise KeyError(message)
            else:
                logging.getLogger(__name__).warning(message)

    return dct
610455
def deep_merge(*args):
    
    if len(args) == 0:
        return None

    if len(args) == 1:
        return copy.deepcopy(args[0])

    lst = list(args)
    last = copy.deepcopy(lst.pop(len(lst) - 1))

    return _deep_merge(deep_merge(*lst), last)
621197
def deep_merge(source, options = {})
      default_opts = {:preserve_unmergeables => true}
      DeepMerge::deep_merge!(source, self, default_opts.merge(options))
    end
232962
def copy_config(config, mutable_config_keys=MUTABLE_CONFIG_KEYS):
    

    cloned_config = copy(config)
    # Apply ``copy`` function to mutable config values
    for key in mutable_config_keys:
        cloned_config[key] = copy(config[key])
    return cloned_config
1054558
def apply(self, config, raise_on_unknown_key=True):
        # type: (Dict[str, Any], bool) -> None
        
        _recursive_merge(self._data, config, raise_on_unknown_key)
445086
def merge_template_options(default_options, template_key, custom_options = {})
      template_options = configuration.template_options.fetch template_key, {}
      options = Wingtips::HashUtils.deep_merge(default_options, template_options)
      Wingtips::HashUtils.deep_merge(options, custom_options)
    end
825451
def ko_deeper_merge!(source, options = {})
      default_opts = {:knockout_prefix => "--", :preserve_unmergeables => false}
      DeepMerge::deep_merge!(source, self, default_opts.merge(options))
    end
994096
private Object mergeReferenceAttributes(String attributeName, EvaluationContext context, ExtendedAttributeDefinition attributeDef, ConfigElement config, Object rawValues) {
        Object rawValue;
        String[] referenceAttributes = getReferenceAttributes(attributeName);
        context.addProcessed(referenceAttributes[0]);
        context.addProcessed(referenceAttributes[1]);
        // get value for the nested element
        rawValue = config.getAttribute(referenceAttributes[1]);
        if (rawValue == null) {
            // if no nested element, then lookup the attribute
            rawValue = config.getAttribute(referenceAttributes[0]);
        } else if (attributeDef.getCardinality() != 0) {
            // we have nested element and attribute allows multiple
            // we must merge if attribute is non null
            Object refRawValue = config.getAttribute(referenceAttributes[0]);
            if (refRawValue != null) {
                rawValue = mergeReferenceValues(attributeDef, refRawValue, rawValue);
            }
        } else {
            // nested value wins if cardinality == 0
        }
        if (rawValues == null) {
            return rawValue;
        }
        if (rawValue == null || attributeDef.getCardinality() == 0) {
            return rawValues;
        }
        return mergeReferenceValues(attributeDef, rawValues, rawValue);
    }
4294
function config(name, options) {
    if (isObject(name)) {
      extend(global, name);
      return;
    }
    var previous = (registry[name] && registry[name].$config) ? registry[name].$config() : null,
        base = extend({}, previous ? extend({}, previous) : extend({}, DEFAULTS, DEFAULT_METHODS));

    options = deepExtend(copy(base), options);

    if (!options.url) {
      options.url = global.base.replace(/\/$/, '') + '/' + hyphenate(name);
    }
    registry[name] = new ModelClass(options);
  }
561725
def with_fallback(self, config, resolve=True):
        
        if isinstance(config, ConfigTree):
            result = ConfigTree.merge_configs(copy.deepcopy(config), copy.deepcopy(self))
        else:
            from . import ConfigFactory
            result = ConfigTree.merge_configs(ConfigFactory.parse_file(config, resolve=False), copy.deepcopy(self))

        if resolve:
            from . import ConfigParser
            ConfigParser.resolve_substitutions(result)
        return result