class LRUCache { capacity : number ; cache : Map < number , number > ; param { number } capacity constructor ( capacity ) { this . capacity = capacity ; this . cache = new Map ( ) ; } param { number } key return { number } public get ( key ) { let cache = this . cache ; if ( cache . has ( key ) ) { let returnVal = cache . get ( key ) ; cache . delete ( key ) ; cache . set ( key , returnVal ) ; return returnVal ; } else { return - 1 ; } } param { number } key param { number } value return { void } public put ( key , value ) { let cache = this . cache ; if ( cache . has ( key ) ) { cache . delete ( key ) ; cache . set ( key , value ) ; } else if ( cache . size === this . capacity ) { cache . delete ( cache . keys ( ) . next ( ) . value ) ; cache . set ( key , value ) ; } else { cache . set ( key , value ) ; } } ; } export { LRUCache } ;