'use strict';

// MODULES //

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


// FUNCTIONS //

/**
* Returns an array element.
*
* @private
* @param {integer} i - index for first dimension
* @param {integer} j - index for second dimension
* @throws {TypeError} index for first dimension must be an integer value
* @throws {TypeError} index for second dimension must be an integer value
* @returns {*} array element
*/
function get( i, j ) {
	/* eslint-disable no-invalid-this */
	var idx;
	if ( !isInteger( i ) ) {
		throw new TypeError( 'invalid input argument. Index for first dimension must be an integer value. Value: `'+i+'`.' );
	}
	if ( !isInteger( j ) ) {
		throw new TypeError( 'invalid input argument. Index for second dimension must be an integer value. Value: `'+j+'`.' );
	}
	// TODO: support index modes

	idx = this._offset + ( this._strides[0]*i ) + ( this._strides[1]*j );
	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} i - index for first dimension
* @param {integer} j - index for second dimension
* @throws {TypeError} index for first dimension must be an integer value
* @throws {TypeError} index for second dimension must be an integer value
* @returns {*} array element
*/
function get( i, j ) {
	/* eslint-disable no-invalid-this */
	var idx;
	if ( !isInteger( i ) ) {
		throw new TypeError( 'invalid input argument. Index for first dimension must be an integer value. Value: `'+i+'`.' );
	}
	if ( !isInteger( j ) ) {
		throw new TypeError( 'invalid input argument. Index for second dimension must be an integer value. Value: `'+j+'`.' );
	}
	i = getIndex( i, this._shape[ 0 ], this._mode );
	j = getIndex( j, this._shape[ 1 ], this._mode );
	idx = this._offset + ( this._strides[0]*i ) + ( this._strides[1]*j );
	return this._buffer[ idx ];
} // end FUNCTION get()


// EXPORTS //

module.exports = get;

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