'use strict';

// MODULES //

var isFunction = require( '@stdlib/utils/is-function' );


// MAIN //

/**
* Returns a function that invokes a provided function with arguments in reverse order.
*
* @param {Function} fcn - input function
* @param {*} [thisArg] - function context
* @throws {TypeError} must provide a function
* @returns {Function} reverse arguments function
*
* @example
* function foo( a, b, c ) {
*     return [ a, b, c ];
* }
*
* var bar = reverseArguments( foo );
*
* var out = bar( 1, 2, 3 );
* // returns [ 3, 2, 1 ]
*/
function reverseArguments( fcn, thisArg ) {
	if ( !isFunction( fcn ) ) {
		throw new TypeError( 'invalid input value. First argument must be a function. Value: `'+fcn+'`.' );
	}
	return reversed;

	/**
	* Invokes a function with arguments in reverse order.
	*
	* @private
	* @param {...*} args - arguments
	* @returns {*} return value
	*/
	function reversed() {
		var args;
		var len;
		var i;

		len = arguments.length;
		args = new Array( len );
		for ( i = 0; i < len; i++ ) {
			args[ len-1-i ] = arguments[ i ];
		}
		return fcn.apply( thisArg, args );
	} // end FUNCTION reversed()
} // end FUNCTION reverseArguments()


// EXPORTS //

module.exports = reverseArguments;

@@ -296,19 +296,29 @@
 or%7D 
-must provid
+first argument must b
 e a 

Update throws description