function offset( x ) {
	var st;
	var sh;
	var n;

	// Note: we intentionally avoid rigorous ndarray checks to minimize performance impacts. This obviously means that non-ndarray-like objects can sneak through, but this is likely all right for the purposes of this function...
	if ( typeof x !== 'object' || x === null ) {
		throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );
	}
	n = x.offset;
	if ( isNonNegativeInteger( n ) ) {
		return n;
	}
	sh = x.shape;
	if ( !isCollection( sh ) ) {
		throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );
	}
	st = x.strides;
	if ( sh.length === 0 || !isCollection( st ) ) {
		return 0;
	}
	n = strides2offset( sh, st );
	if ( isNonNegativeInteger( n ) ) {
		return n;
	}
	throw new TypeError( format( 'invalid argument. Must provide an ndarray. Value: `%s`.', x ) );
}
Returns the index offset specifying the underlying buffer index of the first iterated ndarray element.

@param {ndarrayLike} x - input ndarray
@throws {TypeError} must provide an ndarray
@returns {NonNegativeInteger} index offset

@example
var zeros = require( '@stdlib/ndarray/zeros' );

var n = offset( zeros( [ 3, 3, 3 ] ) );
// returns 0