export default class AxleHeaders { private headers : Headers ; constructor ( headers ) { this . headers = headers ; } public append ( name , value ) { this . headers . append ( name , value ) ; } public delete ( name ) { if ( this . has ( name ) ) { this . headers . delete ( name ) ; return true ; } else { return false ; } } public deleteByValue ( value ) { const found = Object . keys ( this . object ( ) ) . find ( ( key ) => this . object ( ) [ key ] === value ) ; if ( found ) { delete this . object ( ) [ found ] ; return true ; } else { return false ; } } public get entries ( ) { return this . headers . entries ( ) ; } public get ( name ) { return this . headers . get ( name ) ; } public getByValue ( value ) { return Object . keys ( this . object ( ) ) . find ( ( key ) => this . object ( ) [ key ] === value ) ; } public set ( name , value , ifExists = false ) { if ( ifExists ) { if ( this . has ( name ) ) { this . headers . set ( name , value ) ; return true ; } else { return false ; } } else { return false ; } } public has ( name ) { return this . headers . has ( name ) ; } public hasValue ( value ) { const values = this . valueArray ( ) ; for ( let i = 0 ; i < values . length ; i ++ ) { const item = values [ i ] ; if ( item === value ) { return true ; } else { if ( i !== values . length ) { continue ; } else { return false ; } } } } public each ( cb ) { const obj = this . object ( ) ; Object . keys ( obj ) . forEach ( ( key , index ) => { return cb ( key , obj [ key ] , index ) ; } ) ; } public keys ( ) { return this . headers . keys ( ) ; } public values ( ) { return this . headers . values ( ) ; } public keyArray ( ) { return [ ... this . keys ( ) ] ; } public valueArray ( ) { return [ ... this . values ( ) ] ; } public object ( ) { return Object . fromEntries ( this . entries ) ; } public is ( name , value ) { if ( this . has ( name ) ) { return this . get ( name ) === value ; } else { return null ; } } public includesValue ( name , value ) { if ( this . has ( name ) ) { return this . get ( name ) ?. includes ( value ) || false ; } else { return null ; } } public get basic ( ) { return { ... this . headers } ; } }