encoder.js
function encodeArray_Primitive( encoder, data ) {

	// Analyze primitive array and return clusters of values
	// that can be efficiently merged (such as numbers, repeated values,
	// primitives etc.)
	var chunks = analyzePrimitiveArray( encoder, data );
	if (chunks.length === 1) {

		// Just check
		if (chunks[0][1] !== data.length) {
			throw new Errors.AssertError('Primitive array analysis reported single chunk but does not match array length!');
		}

		// Just encode a single chunk as array component
		encodeArray_Chunk( encoder, data, chunks[0] );

	} else {

		// We have more than one chunk, start encoding chunked array
		encodeArray_PRIM_CHUNK( encoder, data, chunks );

	}

}
function encodeArray_Primitive( encoder, data ) {

	// Analyze primitive array and return clusters of values
	// that can be efficiently merged (such as numbers, repeated values,
	// primitives etc.)
	var chunks = analyzePrimitiveArray( encoder, data );
	if (chunks.length === 1) {

		// Just check
		if (chunks[0][1] !== data.length) {
			throw new Errors.AssertError('Primitive array analysis reported single chunk but does not match array length!');
		}

		// Just encode a single chunk as array component
		encodeArray_Chunk( encoder, data, chunks[0] );

	} else {

		// We have more than one chunk, start encoding chunked array
		encodeArray_PRIM_CHUNK( encoder, data, chunks );

	}

}
function encodeArray_Primitive ( encoder , data ) { // Analyze primitive array and return clusters of values // that can be efficiently merged (such as numbers, repeated values, // primitives etc.) var chunks = analyzePrimitiveArray ( encoder , data ) ; if ( chunks . length === 1 ) { // Just check if ( chunks [ 0 ] [ 1 ] !== data . length ) { throw new Errors . AssertError ( 'Primitive array analysis reported single chunk but does not match array length!' ) ; } // Just encode a single chunk as array component encodeArray_Chunk ( encoder , data , chunks [ 0 ] ) ; } else { // We have more than one chunk, start encoding chunked array encodeArray_PRIM_CHUNK ( encoder , data , chunks ) ; } }
Encode an array that is already classified as primitive
Encode an array that is already classified as primitive