function throwIfOutOfBounds( idx, max ) {
	if ( idx < 0 || idx > max ) {
		throw new RangeError( format( 'invalid argument. Index must resolve to a value on the interval: [0, %d]. Value: `%d`.', max, idx ) );
	}
	return idx;
}
Returns an index if within bounds and throw an error otherwise.

@private
@param {integer} idx - index
@param {NonNegativeInteger} max - maximum index
@throws {RangeError} index out-of-bounds
@returns {integer} index

@example
var idx = throwIfOutOfBounds( 2, 9 );
// returns 2

idx = throwIfOutOfBounds( 10, 9 );
// throws <RangeError>

idx = throwIfOutOfBounds( -1, 9 );
// throws <RangeError>