merge-deep/merge-deep.js
function mergeMap(instance, data) {

	// for each key in
	canReflect.eachKey(instance, function(value, prop) {
		if(!canReflect.hasKey(data, prop)) {
			canReflect.deleteKeyValue(instance, prop);
			return;
		}
		var newValue = canReflect.getKeyValue(data, prop);
		canReflect.deleteKeyValue(data, prop);

		// cases:
		// a. list
		// b. map
		// c. primitive

		// if the data is typed, we would just replace it
		if (canReflect.isPrimitive(value)) {
			canReflect.setKeyValue(instance, prop, newValue);
			return;
		}


		var newValueIsList = Array.isArray(newValue),
			currentValueIsList = canReflect.isMoreListLikeThanMapLike(value);

		if (currentValueIsList && newValueIsList) {

			mergeList(value, newValue);

		} else if (!newValueIsList && !currentValueIsList && canReflect.isMapLike(value) && canReflect.isPlainObject(newValue)) {

			// TODO: the `TYPE` should probably be infered from the `_define` property definition.
			var schema = canReflect.getSchema(value);
			if (schema && schema.identity && schema.identity.length) {
				var id = canReflect.getIdentity(value, schema);
				if (id != null && id === canReflect.getIdentity(newValue, schema)) {
					mergeMap(value, newValue);
					return;
				}
			}
			canReflect.setKeyValue(instance, prop, canReflect.new(value.constructor, newValue));
		} else {
			canReflect.setKeyValue(instance, prop, newValue);
		}
	});
	canReflect.eachKey(data, function(value, prop) {
		canReflect.setKeyValue(instance, prop, value);
	});
}
function mergeMap(instance, data) {

	// for each key in
	canReflect.eachKey(instance, function(value, prop) {
		if(!canReflect.hasKey(data, prop)) {
			canReflect.deleteKeyValue(instance, prop);
			return;
		}
		var newValue = canReflect.getKeyValue(data, prop);
		canReflect.deleteKeyValue(data, prop);

		// cases:
		// a. list
		// b. map
		// c. primitive

		// if the data is typed, we would just replace it
		if (canReflect.isPrimitive(value)) {
			canReflect.setKeyValue(instance, prop, newValue);
			return;
		}


		var newValueIsList = Array.isArray(newValue),
			currentValueIsList = canReflect.isMoreListLikeThanMapLike(value);

		if (currentValueIsList && newValueIsList) {

			mergeList(value, newValue);

		} else if (!newValueIsList && !currentValueIsList && canReflect.isMapLike(value) && canReflect.isPlainObject(newValue)) {

			// TODO: the `TYPE` should probably be infered from the `_define` property definition.
			var schema = canReflect.getSchema(value);
			if (schema && schema.identity && schema.identity.length) {
				var id = canReflect.getIdentity(value, schema);
				if (id != null && id === canReflect.getIdentity(newValue, schema)) {
					mergeMap(value, newValue);
					return;
				}
			}
			canReflect.setKeyValue(instance, prop, canReflect.new(value.constructor, newValue));
		} else {
			canReflect.setKeyValue(instance, prop, newValue);
		}
	});
	canReflect.eachKey(data, function(value, prop) {
		canReflect.setKeyValue(instance, prop, value);
	});
}
function mergeMap ( instance , data ) { // for each key in canReflect . eachKey ( instance , function ( value , prop ) { if ( ! canReflect . hasKey ( data , prop ) ) { canReflect . deleteKeyValue ( instance , prop ) ; return ; } var newValue = canReflect . getKeyValue ( data , prop ) ; canReflect . deleteKeyValue ( data , prop ) ; // cases: // a. list // b. map // c. primitive // if the data is typed, we would just replace it if ( canReflect . isPrimitive ( value ) ) { canReflect . setKeyValue ( instance , prop , newValue ) ; return ; } var newValueIsList = Array . isArray ( newValue ) , currentValueIsList = canReflect . isMoreListLikeThanMapLike ( value ) ; if ( currentValueIsList && newValueIsList ) { mergeList ( value , newValue ) ; } else if ( ! newValueIsList && ! currentValueIsList && canReflect . isMapLike ( value ) && canReflect . isPlainObject ( newValue ) ) { // TODO: the `TYPE` should probably be infered from the `_define` property definition. var schema = canReflect . getSchema ( value ) ; if ( schema && schema . identity && schema . identity . length ) { var id = canReflect . getIdentity ( value , schema ) ; if ( id != null && id === canReflect . getIdentity ( newValue , schema ) ) { mergeMap ( value , newValue ) ; return ; } } canReflect . setKeyValue ( instance , prop , canReflect . new ( value . constructor , newValue ) ) ; } else { canReflect . setKeyValue ( instance , prop , newValue ) ; } } ) ; canReflect . eachKey ( data , function ( value , prop ) { canReflect . setKeyValue ( instance , prop , value ) ; } ) ; }
date is expected to be mutable here
date is expected to be mutable here