class Cache < T > { static readonly populatedBy = < T > ( populate ) => new Cache ( populate ) ; private readonly populate : ( ) => T ; private value : T | undefined ; private constructor ( populate ) { this . populate = populate ; this . value = undefined ; } getValue ( ) { return this . value ; } access ( ) { if ( ! this . value ) this . value = this . populate ( ) ; return this . value ; } invalidate ( ) { this . value = undefined ; } } export default Cache ;