function memoize( fcn, hashFunction ) {
	var toKey;
	var cache;
	if ( !isFunction( fcn ) ) {
		throw new TypeError( format( 'invalid argument. First argument must be a function. Value: `%s`.', fcn ) );
	}
	if ( arguments.length < 2 ) {
		toKey = identity;
	} else {
		toKey = hashFunction;
		if ( !isFunction( toKey ) ) {
			throw new TypeError( format( 'invalid argument. Hash function argument must be a function. Value: `%s`.', toKey ) );
		}
	}
	cache = {};
	setReadOnly( memoized, 'cache', cache );
	return memoized;

	/**
	* Memoized function.
	*
	* @private
	* @param {...*} args - function arguments
	* @returns {*} memoized function result
	*/
	function memoized() {
		var args;
		var out;
		var key;
		var i;
		args = new Array( arguments.length );
		for ( i = 0; i < arguments.length; i++ ) {
			args[ i ] = arguments[ i ];
		}
		key = toKey( args ).toString();
		if ( hasOwnProp( cache, key ) ) {
			return cache[ key ];
		}
		out = fcn.apply( null, args );
		cache[ key ] = out;
		return out;
	}
}
Returns a memoized function.

@param {Function} fcn - function to memoize
@param {Function} [hashFunction] - function to map a set of arguments to a single value identifying that set
@throws {TypeError} first argument must be a function
@throws {TypeError} second argument must be a function
@returns {Function} memoized function

@example
function factorial( n ) {
    var prod;
    var i;
    prod = 1;
    for ( i = n; i > 1; i-- ) {
        prod *= i;
    }
    return prod;
}

var memoized = memoize( factorial );

var v = memoized( 5 );
// returns 120

v = memoized( 5 );
// returns 120