@@ -93,31 +93,31 @@ utils.addByteCodes(BYTE_CODES, [
9393 * @return {Number }
9494 * @api public
9595 */
96- proto . readInt = function ( ) {
96+ proto . readInt = function ( withType ) {
9797 var code = this . byteBuffer . get ( ) ;
98+ var val ;
9899 // Compact int
99100 if ( code >= 0x80 && code <= 0xbf ) {
100101 // Integers between -16 and 47 can be encoded by a single octet in the range x80 to xbf.
101102 // value = code - 0x90
102- return code - 0x90 ;
103- }
104- if ( code >= 0xc0 && code <= 0xcf ) {
103+ val = code - 0x90 ;
104+ } else if ( code >= 0xc0 && code <= 0xcf ) {
105105 // Integers between -2048 and 2047 can be encoded in two octets with the leading byte in the range xc0 to xcf.
106106 // value = ((code - 0xc8) << 8) + b0;
107- return ( ( code - 0xc8 ) << 8 ) + this . byteBuffer . get ( ) ;
108- }
109- if ( code >= 0xd0 && code <= 0xd7 ) {
107+ val = ( ( code - 0xc8 ) << 8 ) + this . byteBuffer . get ( ) ;
108+ } else if ( code >= 0xd0 && code <= 0xd7 ) {
110109 // Integers between -262144 and 262143 can be encoded in three bytes with the leading byte in the range xd0 to xd7.
111110 // value = ((code - 0xd4) << 16) + (b1 << 8) + b0;
112111 var b1 = this . byteBuffer . get ( ) ;
113112 var b0 = this . byteBuffer . get ( ) ;
114- return ( ( code - 0xd4 ) << 16 ) + ( b1 << 8 ) + b0 ;
115- }
116- if ( code === 0x49 ) {
117- return this . byteBuffer . getInt ( ) ;
113+ val = ( ( code - 0xd4 ) << 16 ) + ( b1 << 8 ) + b0 ;
114+ } else if ( code === 0x49 ) {
115+ val = this . byteBuffer . getInt ( ) ;
116+ } else {
117+ this . throwError ( 'readInt' , code ) ;
118118 }
119-
120- this . throwError ( 'readInt ', code ) ;
119+
120+ return this . handleType ( 'int ', val , withType ) ;
121121} ;
122122
123123utils . addByteCodes ( BYTE_CODES , [
0 commit comments