function copy2buffer( x, shape ) {
	var out;
	var buf;
	var idx;
	var ord;
	var sx;
	var ox;
	var N;
	var v;
	var i;

	// Cache ndarray meta data:
	buf = x.data;
	ord = x.order;
	sx = x.strides;
	ox = x.offset;

	// Compute the number of array elements:
	N = numel( shape );

	// Allocate a data buffer:
	out = new Float64Array( N );

	// Iterate over the ndarray and copy elements to a new buffer...
	for ( i = 0; i < N; i++ ) {
		idx = vind2bind( shape, sx, ox, ord, i, MODE );
		v = buf[ idx ];
		if ( !isNonNegativeInteger( v ) ) {
			throw new TypeError( format( 'invalid argument. First argument must contain nonnegative integers. Indices: (%s). Value: `%s`.', ind2sub( shape, sx, ox, ord, i, MODE ), String( v ) ) );
		}
		out[ i ] = v;
	}
	return out;
}
Copies ndarray data to a new data buffer.

@private
@param {ndarrayLike} x - input ndarray-like object
@param {NonNegativeIntegerArray} shape - array shape
@throws {TypeError} first argument must contain nonnegative integers
@returns {Float64Array} data buffer