/**
 * Map with case-insensitive keys. Last set wins if keys differ only by case
 */ export class CaseInsensitiveMap < TKey extends string , TValue > { private _map : Map < TKey , [ TKey , TValue ] > = new Map < TKey , [ TKey , TValue ] > ( ) ; public get size ( ) : number { return this . _map . size ; } public get ( key ) { const found = this . _map . get ( < TKey > key . toLowerCase ( ) ) ; return found ? found [ 1 ] : undefined ; } public set ( key , value ) { this . _map . set ( < TKey > key . toLowerCase ( ) , [ key , value ] ) ; return this ; } /**
     * Retrieve the keys, in the original casing that they were set with
     */ public keys ( ) { const tuples = Array . from ( this . _map . values ( ) ) ; const casePreservedKeys = tuples . map ( tuple => tuple [ 0 ] ) ; return casePreservedKeys . values ( ) ; } public entries ( ) { return Array . from ( this . _map . values ( ) ) ; } public map < TReturn > ( callbackfn ) { const array = [ ] ; this . _map . forEach ( ( entry ) => { array . push ( callbackfn ( entry [ 0 ] , entry [ 1 ] ) ) ; } ) ; return array ; } }