/**
 * Caches a value on the first call and always returns the same value after that
 */ export class CachedValue < T > { private _isCached : boolean = false ; private _value ! : T ; public getOrCacheValue ( calculateValue ) { if ( ! this . _isCached ) { this . _value = calculateValue ( ) ; this . _isCached = true ; } return this . _value ; } public clear ( ) { this . _isCached = false ; this . _value = < T > < unknown > undefined ; } }