encoder.js
function encodeArray_PRIM_RAW( encoder, data ) {

	//
	// Raw Primitive Array (PRIM_RAW)
	//
	// .......  .   + Signature ID
	// 0110101 [LN]     [16-bit]
	//

	// Write chunk header
	encoder.counters.arr_prim_raw+=1;
	encoder.log(LOG.ARR, "array.prim.raw, len="+data.length+
		", peek="+data[0]+" [");
	encoder.logIndent(1);

	if (data.length < UINT16_MAX) { // 16-bit length prefix
		encoder.stream8.write( pack1b( ARR_OP.PRIM_RAW | NUMTYPE_LN.UINT16 ) );
		encoder.stream16.write( pack2b( data.length, false ) );
		encoder.counters.arr_hdr+=3;
	} else { // 32-bit length prefix
		encoder.stream8.write( pack1b( ARR_OP.PRIM_RAW | NUMTYPE_LN.UINT32 ) );
		encoder.stream32.write( pack4b( data.length, false ) );
		encoder.counters.arr_hdr+=5;
	}

	// Write primitives
	for (var i=0, l=data.length; i<l; ++i)
		encodePrimitive( encoder, data[i] );

	// Close log group
	encoder.logIndent(-1);
	encoder.log(LOG.ARR, "]");

}
function encodeArray_PRIM_RAW( encoder, data ) {

	//
	// Raw Primitive Array (PRIM_RAW)
	//
	// .......  .   + Signature ID
	// 0110101 [LN]     [16-bit]
	//

	// Write chunk header
	encoder.counters.arr_prim_raw+=1;
	encoder.log(LOG.ARR, "array.prim.raw, len="+data.length+
		", peek="+data[0]+" [");
	encoder.logIndent(1);

	if (data.length < UINT16_MAX) { // 16-bit length prefix
		encoder.stream8.write( pack1b( ARR_OP.PRIM_RAW | NUMTYPE_LN.UINT16 ) );
		encoder.stream16.write( pack2b( data.length, false ) );
		encoder.counters.arr_hdr+=3;
	} else { // 32-bit length prefix
		encoder.stream8.write( pack1b( ARR_OP.PRIM_RAW | NUMTYPE_LN.UINT32 ) );
		encoder.stream32.write( pack4b( data.length, false ) );
		encoder.counters.arr_hdr+=5;
	}

	// Write primitives
	for (var i=0, l=data.length; i<l; ++i)
		encodePrimitive( encoder, data[i] );

	// Close log group
	encoder.logIndent(-1);
	encoder.log(LOG.ARR, "]");

}
function encodeArray_PRIM_RAW ( encoder , data ) { // // Raw Primitive Array (PRIM_RAW) // // .......  .   + Signature ID // 0110101 [LN]     [16-bit] // // Write chunk header encoder . counters . arr_prim_raw += 1 ; encoder . log ( LOG . ARR , "array.prim.raw, len=" + data . length + ", peek=" + data [ 0 ] + " [" ) ; encoder . logIndent ( 1 ) ; if ( data . length < UINT16_MAX ) { // 16-bit length prefix encoder . stream8 . write ( pack1b ( ARR_OP . PRIM_RAW | NUMTYPE_LN . UINT16 ) ) ; encoder . stream16 . write ( pack2b ( data . length , false ) ) ; encoder . counters . arr_hdr += 3 ; } else { // 32-bit length prefix encoder . stream8 . write ( pack1b ( ARR_OP . PRIM_RAW | NUMTYPE_LN . UINT32 ) ) ; encoder . stream32 . write ( pack4b ( data . length , false ) ) ; encoder . counters . arr_hdr += 5 ; } // Write primitives for ( var i = 0 , l = data . length ; i < l ; ++ i ) encodePrimitive ( encoder , data [ i ] ) ; // Close log group encoder . logIndent ( - 1 ) ; encoder . log ( LOG . ARR , "]" ) ; }
Encode a number of consecutive primitives
Encode a number of consecutive primitives