function buffer2json( buffer ) {
	var out;
	var i;
	if ( !isBuffer( buffer ) ) {
		throw new TypeError( format( 'invalid argument. Must provide a Buffer. Value: `%s`.', buffer ) );
	}
	out = {};
	out.type = 'Buffer';
	out.data = [];
	for ( i = 0; i < buffer.length; i++ ) {
		out.data.push( buffer[ i ] );
	}
	return out;
}
Returns a JSON representation of a `Buffer`.

@param {Buffer} buffer - buffer to serialize
@throws {TypeError} first argument must be a `Buffer`
@returns {Object} JSON representation

@example
var array2buffer = require( '@stdlib/buffer/from-array' );

var buf = array2buffer( [ 1, 2 ] );
// returns <Buffer>

var json = buffer2json( buf );
// returns { 'type': 'Buffer', 'data': [ 1, 2 ] }