'use strict';

/**
* Moves a property from one object to another object.
*
* @param {Object} source - source object
* @param {string} prop - property to move
* @param {Object} target - target object
* @returns {boolean} boolean indicating whether operation was successful
*
* @example
* var obj1 = { 'a': 'b' };
* var obj2 = {};
*
* var bool = moveProperty( obj1, 'a', obj2 );
* // returns true
* @example
* var obj1 = { 'a': 'b' };
* var obj2 = {};
*
* var bool = moveProperty( obj1, 'c', obj2 );
* // returns false
*/
function moveProperty( source, prop, target ) {
	var desc;
	if ( typeof source !== 'object' || source === null ) {
		throw new TypeError( 'invalid input argument. Source argument must be an object. Value: `' + source + '`.' );
	}
	if ( typeof target !== 'object' || target === null ) {
		throw new TypeError( 'invalid input argument. Target argument must be an object. Value: `' + target + '`.' );
	}
	// TODO: handle case where gOPD is not supported
	desc = Object.getOwnPropertyDescriptor( source, prop );
	if ( desc === void 0 ) {
		return false;
	}
	delete source[ prop ];
	Object.defineProperty( target, prop, desc );
	return true;
} // end FUNCTION moveProperty()


// EXPORTS //

module.exports = moveProperty;

'use strict';

/**
* Moves a property from one object to another object.
*
* @param {Object} source - source object
* @param {string} prop - property to move
* @param {Object} target - target object
* @throws {TypeError} first argument must be an object
* @throws {TypeError} second argument must be an object
* @returns {boolean} boolean indicating whether operation was successful
*
* @example
* var obj1 = { 'a': 'b' };
* var obj2 = {};
*
* var bool = moveProperty( obj1, 'a', obj2 );
* // returns true
* @example
* var obj1 = { 'a': 'b' };
* var obj2 = {};
*
* var bool = moveProperty( obj1, 'c', obj2 );
* // returns false
*/
function moveProperty( source, prop, target ) {
	var desc;
	if ( typeof source !== 'object' || source === null ) {
		throw new TypeError( 'invalid input argument. Source argument must be an object. Value: `' + source + '`.' );
	}
	if ( typeof target !== 'object' || target === null ) {
		throw new TypeError( 'invalid input argument. Target argument must be an object. Value: `' + target + '`.' );
	}
	// TODO: handle case where gOPD is not supported
	desc = Object.getOwnPropertyDescriptor( source, prop );
	if ( desc === void 0 ) {
		return false;
	}
	delete source[ prop ];
	Object.defineProperty( target, prop, desc );
	return true;
} // end FUNCTION moveProperty()


// EXPORTS //

module.exports = moveProperty;

Add throws annotations