export function toHeaderCase ( header ) { return header . split ( '-' ) . map ( ( segment ) => segment . charAt ( 0 ) . toUpperCase ( ) + segment . substr ( 1 ) . toLowerCase ( ) ) . join ( '-' ) ; } export function remapKeys < T > ( obj , mapFn ) { return { ... Object . keys ( obj ) . reduce ( ( acc , key ) => ( { ... acc , [ mapFn ( key ) ] : obj [ key ] } ) , { } ) , } ; } const caseInsensitiveHandler = { set : ( target , attribute , value ) : boolean => { target [ attribute . toString ( ) . toLowerCase ( ) ] = value ; return true ; } , get : ( target , attribute ) => { return target [ attribute . toString ( ) . toLowerCase ( ) ] ; } , } ; export class CaseInsensitiveObject { [ attribute ] : string ; constructor ( ) { return new Proxy ( this , caseInsensitiveHandler ) ; } } const defaultMultiValueHandler = { get : ( target , attribute ) => { return target . hasOwnProperty ( attribute ) ? target [ attribute . toString ( ) ] : [ ] ; } , } ; export class DefaultMultiValueObject { [ attribute ] : string [ ] ; constructor ( ) { return new Proxy ( this , defaultMultiValueHandler ) ; } } const caseInsensitiveDefaultMultiValueHandler = { get : ( target , attribute ) : string [ ] => { return target . hasOwnProperty ( attribute ) ? target [ attribute . toString ( ) ] : [ ] ; } , set : ( target , attribute , value ) : boolean => { if ( typeof value === 'string' ) { const newValue = [ ... target [ attribute . toString ( ) . toLowerCase ( ) ] , value ] ; } else { target [ attribute . toString ( ) . toLowerCase ( ) ] = value ; } return true ; } , } ; export class CaseInsensitiveDefaultMultiValueObject { [ attribute ] : string [ ] ; constructor ( ) { return new Proxy ( this , defaultMultiValueHandler ) ; } }