export class ByteReader { private position = 0 ; constructor ( private value ) { if ( value . startsWith ( '0x' ) ) { this . value = value . slice ( 2 ) ; } } getBytes ( n ) { const bytes = this . value . slice ( this . position * 2 , ( this . position + n ) * 2 ) ; this . position += n ; return bytes ; } getNumber ( n ) { const bytes = this . getBytes ( n ) ; return parseInt ( bytes , 16 ) ; } }