function ind( idx, max, mode ) {
	var index;
	if ( mode === 'clamp' ) {
		return clampIndex( idx, max );
	}
	if ( mode === 'wrap' ) {
		return wrapIndex( idx, max );
	}
	index = idx;
	if ( mode === 'normalize' ) {
		index = normalizeIndex( index, max );
	}
	if ( index < 0 || index > max ) {
		throw new RangeError( format( 'invalid argument. Index must resolve to a value on the interval: [0, %d]. Value: `%d`.', max, idx ) );
	}
	return index;
}
Returns an index given an index mode.

@param {integer} idx - index
@param {NonNegativeInteger} max - maximum index
@param {string} mode - specifies how to handle an index outside the interval `[0,max]`
@throws {RangeError} index out-of-bounds
@returns {integer} index

@example
var idx = ind( 2, 9, 'clamp' );
// returns 2

idx = ind( 10, 9, 'clamp' );
// returns 9

idx = ind( -1, 9, 'clamp' );
// returns 0

@example
var idx = ind( 2, 9, 'wrap' );
// returns 2

idx = ind( 10, 9, 'wrap' );
// returns 0

idx = ind( -1, 9, 'wrap' );
// returns 9

@example
var idx = ind( 2, 9, 'throw' );
// returns 2

idx = ind( 10, 9, 'throw' );
// throws <RangeError>

idx = ind( -1, 9, 'throw' );
// throws <RangeError>

@example
var idx = ind( 1, 10, 'normalize' );
// returns 1

idx = ind( -4, 10, 'normalize' );
// returns 7

idx = ind( -100, 10, 'normalize' );
// throws <RangeError>