import * as Token from 'token-types' ; export class VorbisDecoder { constructor ( private readonly data , private offset ) { } public readInt32 ( ) { const value = Token . UINT32_LE . get ( this . data , this . offset ) ; this . offset += 4 ; return value ; } public readStringUtf8 ( ) { const len = this . readInt32 ( ) ; const value = Buffer . from ( this . data ) . toString ( 'utf-8' , this . offset , this . offset + len ) ; this . offset += len ; return value ; } public parseUserComment ( ) { const offset0 = this . offset ; const v = this . readStringUtf8 ( ) ; const idx = v . indexOf ( '=' ) ; return { key : v . slice ( 0 , idx ) . toUpperCase ( ) , value : v . slice ( idx + 1 ) , len : this . offset - offset0 } ; } }