decoder.js
function decodeBuffer( bundle, len, buf_type ) {
	var length=0, ans="";
	switch (len) {
		case 0: length = bundle.u8[bundle.i8++]; break;
		case 1: length = bundle.u16[bundle.i16++]; break;
		case 2: length = bundle.u32[bundle.i32++]; break;
		case 3: length = bundle.f64[bundle.i64++]; break;
	}

	// Process buffer according to type
	if (buf_type === 0) { // STRING_LATIN
		ans = String.fromCharCode.apply(null, bundle.readTypedArray( NUMTYPE.UINT8 , length ) );
		return DEBUG
			? __debugMeta( ans, 'string.latin', {} )
			: ans;

	} else if (buf_type === 1) { // STRING_UTF8
		ans = String.fromCharCode.apply(null, bundle.readTypedArray( NUMTYPE.UINT16 , length ) );
		return DEBUG
			? __debugMeta( ans, 'string.utf8', {} )
			: ans;

	} else if (buf_type === 2) { // IMAGE
		var img = document.createElement('img');
		img.src = decodeBlobURL( bundle, length );
		return img;

	} else if (buf_type === 4) { // SCRIPT
		var img = document.createElement('script');
		img.src = decodeBlobURL( bundle, length );
		return img;

	} else if (buf_type === 7) { // RESOURCE
		return decodeBlobURL( bundle, length );

	} else {
		throw new Errors.AssertError('Unknown buffer type #'+buf_type+'!');
	}

}
function decodeBuffer( bundle, len, buf_type ) {
	var length=0, ans="";
	switch (len) {
		case 0: length = bundle.u8[bundle.i8++]; break;
		case 1: length = bundle.u16[bundle.i16++]; break;
		case 2: length = bundle.u32[bundle.i32++]; break;
		case 3: length = bundle.f64[bundle.i64++]; break;
	}

	// Process buffer according to type
	if (buf_type === 0) { // STRING_LATIN
		ans = String.fromCharCode.apply(null, bundle.readTypedArray( NUMTYPE.UINT8 , length ) );
		return DEBUG
			? __debugMeta( ans, 'string.latin', {} )
			: ans;

	} else if (buf_type === 1) { // STRING_UTF8
		ans = String.fromCharCode.apply(null, bundle.readTypedArray( NUMTYPE.UINT16 , length ) );
		return DEBUG
			? __debugMeta( ans, 'string.utf8', {} )
			: ans;

	} else if (buf_type === 2) { // IMAGE
		var img = document.createElement('img');
		img.src = decodeBlobURL( bundle, length );
		return img;

	} else if (buf_type === 4) { // SCRIPT
		var img = document.createElement('script');
		img.src = decodeBlobURL( bundle, length );
		return img;

	} else if (buf_type === 7) { // RESOURCE
		return decodeBlobURL( bundle, length );

	} else {
		throw new Errors.AssertError('Unknown buffer type #'+buf_type+'!');
	}

}
function decodeBuffer ( bundle , len , buf_type ) { var length = 0 , ans = "" ; switch ( len ) { case 0 : length = bundle . u8 [ bundle . i8 ++ ] ; break ; case 1 : length = bundle . u16 [ bundle . i16 ++ ] ; break ; case 2 : length = bundle . u32 [ bundle . i32 ++ ] ; break ; case 3 : length = bundle . f64 [ bundle . i64 ++ ] ; break ; } // Process buffer according to type if ( buf_type === 0 ) { // STRING_LATIN ans = String . fromCharCode . apply ( null , bundle . readTypedArray ( NUMTYPE . UINT8 , length ) ) ; return DEBUG ? __debugMeta ( ans , 'string.latin' , { } ) : ans ; } else if ( buf_type === 1 ) { // STRING_UTF8 ans = String . fromCharCode . apply ( null , bundle . readTypedArray ( NUMTYPE . UINT16 , length ) ) ; return DEBUG ? __debugMeta ( ans , 'string.utf8' , { } ) : ans ; } else if ( buf_type === 2 ) { // IMAGE var img = document . createElement ( 'img' ) ; img . src = decodeBlobURL ( bundle , length ) ; return img ; } else if ( buf_type === 4 ) { // SCRIPT var img = document . createElement ( 'script' ) ; img . src = decodeBlobURL ( bundle , length ) ; return img ; } else if ( buf_type === 7 ) { // RESOURCE return decodeBlobURL ( bundle , length ) ; } else { throw new Errors . AssertError ( 'Unknown buffer type #' + buf_type + '!' ) ; } }
Read a buffer from the bundle
Read a buffer from the bundle