import type { $IntentionalAny } from './types' ; export default class SimpleCache { protected _values : Record < string , unknown > = { } ; constructor ( ) { } get < T > ( key , producer ) { if ( this . has ( key ) ) { return this . _values [ key ] as $IntentionalAny ; } else { const cachedValue = producer ( ) ; this . _values [ key ] = cachedValue ; return cachedValue ; } } has ( key ) { return this . _values . hasOwnProperty ( key ) ; } }