lib/submerge.js
function inherit(options, destination, source, key) {
		var define, override, path;

		if (key in destination) {
			if (isObject(destination[key]) && isObject(source[key])) {
				//  live up to the name and merge the sub objects
				Object.keys(source[key]).forEach(function(k) {
					inherit(options, destination[key], source[key], k);
				});
			}

			return;
		}

		options.path.push(key);
		define = {enumerable: true};

		if (isObject(source[key])) {
			override = combine(options, [source[key]]);
		}
		else if (source[key] instanceof Array) {
			override = monitorArray(source[key], function() {
				options.emitter.emit('change', path, source[key], source[key]);
			});
		}

		if (isTrue(options, 'live')) {
			path = options.path.join('.');

			define.get = function() {
				return override || source[key];
			};

			define.set = function(value) {
				if (isTrue(options, 'locked') || value === destination[key]) {
					return;
				}

				if (isObject(value)) {
					options.path = path.split('.');
					value = combine(options, [value, source[key]]);
				}

				override = null;
				options.emitter.emit('change', path, value, source[key]);
				source[key] = value;
			};
		}
		else {
			define.value = override || source[key];
			define.writable = !isTrue(options, 'locked');
		}

		Object.defineProperty(destination, key, define);

		options.path.pop();
	}
function inherit(options, destination, source, key) {
		var define, override, path;

		if (key in destination) {
			if (isObject(destination[key]) && isObject(source[key])) {
				//  live up to the name and merge the sub objects
				Object.keys(source[key]).forEach(function(k) {
					inherit(options, destination[key], source[key], k);
				});
			}

			return;
		}

		options.path.push(key);
		define = {enumerable: true};

		if (isObject(source[key])) {
			override = combine(options, [source[key]]);
		}
		else if (source[key] instanceof Array) {
			override = monitorArray(source[key], function() {
				options.emitter.emit('change', path, source[key], source[key]);
			});
		}

		if (isTrue(options, 'live')) {
			path = options.path.join('.');

			define.get = function() {
				return override || source[key];
			};

			define.set = function(value) {
				if (isTrue(options, 'locked') || value === destination[key]) {
					return;
				}

				if (isObject(value)) {
					options.path = path.split('.');
					value = combine(options, [value, source[key]]);
				}

				override = null;
				options.emitter.emit('change', path, value, source[key]);
				source[key] = value;
			};
		}
		else {
			define.value = override || source[key];
			define.writable = !isTrue(options, 'locked');
		}

		Object.defineProperty(destination, key, define);

		options.path.pop();
	}
function inherit ( options , destination , source , key ) { var define , override , path ; if ( key in destination ) { if ( isObject ( destination [ key ] ) && isObject ( source [ key ] ) ) { //  live up to the name and merge the sub objects Object . keys ( source [ key ] ) . forEach ( function ( k ) { inherit ( options , destination [ key ] , source [ key ] , k ) ; } ) ; } return ; } options . path . push ( key ) ; define = { enumerable : true } ; if ( isObject ( source [ key ] ) ) { override = combine ( options , [ source [ key ] ] ) ; } else if ( source [ key ] instanceof Array ) { override = monitorArray ( source [ key ] , function ( ) { options . emitter . emit ( 'change' , path , source [ key ] , source [ key ] ) ; } ) ; } if ( isTrue ( options , 'live' ) ) { path = options . path . join ( '.' ) ; define . get = function ( ) { return override || source [ key ] ; } ; define . set = function ( value ) { if ( isTrue ( options , 'locked' ) || value === destination [ key ] ) { return ; } if ( isObject ( value ) ) { options . path = path . split ( '.' ) ; value = combine ( options , [ value , source [ key ] ] ) ; } override = null ; options . emitter . emit ( 'change' , path , value , source [ key ] ) ; source [ key ] = value ; } ; } else { define . value = override || source [ key ] ; define . writable = ! isTrue ( options , 'locked' ) ; } Object . defineProperty ( destination , key , define ) ; options . path . pop ( ) ; }
Inherit the value at key of one object from a single other object
@name    inherit
@access  internal
@param   object options {live:bool, locked:bool}
@param   object destination
@param   object source
@param   string key
@return  void
Inherit the value at key of one object from a single other object