export class export default class BatchRequestHeaders { public constructor ( headers ) { this . rawHeaders = headers ; this . createDictFromRawHeaders ( ) ; } private rawHeaders : string [ ] ; private headerItems : { [ index ] : string ; } = { } ; private headerCount : number = 0 ; return { * } memberof public getRawHeaders ( ) { return this . rawHeaders ; } param { string } key return { * } memberof public containsHeader ( key ) { return this . headerItems . hasOwnProperty ( key ) ; } return { * } memberof public count ( ) { return this . headerCount ; } param { string } key param { string } value memberof public add ( key , value ) { if ( ! this . headerItems . hasOwnProperty ( key ) ) this . headerCount ++ ; this . headerItems [ key ] = value ; } param { string } key return { * } memberof public remove ( key ) { const val = this . headerItems [ key ] ; delete this . headerItems [ key ] ; this . headerCount -- ; return val ; } param { string } key return { * } memberof public header ( key ) { return this . headerItems [ key . toLocaleLowerCase ( ) ] ; } return { * } memberof public headerKeys ( ) { const headers = [ ] ; for ( const prop in this . headerItems ) { if ( this . headerItems . hasOwnProperty ( prop ) ) { headers . push ( prop ) ; } } return headers ; } return { * } memberof public headerValues ( ) { const values = [ ] ; for ( const prop in this . headerItems ) { if ( this . headerItems . hasOwnProperty ( prop ) ) { values . push ( this . headerItems [ prop ] ) ; } } return values ; } private memberof private createDictFromRawHeaders ( ) { this . rawHeaders . forEach ( ( rawheader ) => { if ( rawheader != null ) { const headerMatch = rawheader . match ( /(\S+)(:\s?)(\S+)/ ) ; if ( headerMatch == null && rawheader . length > 2 ) { this . add ( rawheader , "" ) ; } else if ( headerMatch != null ) { this . add ( headerMatch [ 1 ] . toLocaleLowerCase ( ) , headerMatch [ 3 ] ) ; } } } ) ; } }