class LruCache < T > { private values : Map < string , T > = new Map < string , T > ( ) ; private maxEntries = 20 ; public get ( key ) { const hasKey = this . values . has ( key ) ; let entry ; if ( hasKey ) { entry = this . values . get ( key ) ; this . values . delete ( key ) ; if ( typeof entry !== "undefined" ) { this . values . set ( key , entry ) ; } } return entry ; } public set ( key , value ) { if ( this . values . size >= this . maxEntries ) { const keyToDelete = this . values . keys ( ) . next ( ) . value ; this . values . delete ( keyToDelete ) ; } this . values . set ( key , value ) ; } public delete ( key ) { this . values . delete ( key ) ; } } export { LruCache } ;