'use strict';

// MODULES //

var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive;


// FUNCTIONS //

/**
* Returns an array element.
*
* @private
* @param {...integer} idx - indices
* @throws {TypeError} provided indices must be integer valued
* @throws {RangeError} index exceeds array dimensions
* @returns {*} array element
*/
function get() {
	/* eslint-disable no-invalid-this */
	var len;
	var idx;
	var i;

	// TODO: support index modes

	len = arguments.length;
	idx = this._offset;
	for ( i = 0; i < len; i++ ) {
		if ( !isInteger( arguments[ i ] ) ) {
			throw new TypeError( 'invalid input argument. Indices must be integer valued. Argument: '+i+'. Value: `'+arguments[i]+'`.' );
		}
		idx += this._strides[ i ] * arguments[ i ];
	}
	return this._buffer[ idx ];
} // end FUNCTION get()


// EXPORTS //

module.exports = get;

'use strict';

// MODULES //

var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive;
var getIndex = require( './get_index.js' );


// FUNCTIONS //

/**
* Returns an array element.
*
* @private
* @param {...integer} idx - indices
* @throws {TypeError} provided indices must be integer valued
* @throws {RangeError} index exceeds array dimensions
* @returns {*} array element
*/
function get() {
	/* eslint-disable no-invalid-this */
	var len;
	var idx;
	var ind;
	var i;

	len = arguments.length;
	idx = this._offset;
	for ( i = 0; i < len; i++ ) {
		if ( !isInteger( arguments[ i ] ) ) {
			throw new TypeError( 'invalid input argument. Indices must be integer valued. Argument: '+i+'. Value: `'+arguments[i]+'`.' );
		}
		ind = getIndex( arguments[ i ], this._shape[ i ], this._mode );
		idx += this._strides[ i ] * ind;
	}
	return this._buffer[ idx ];
} // end FUNCTION get()


// EXPORTS //

module.exports = get;

Add support for an index mode
Add support for an index mode
