import { Bot , PrecalculatedBot } from './Bot' ; import { BotLookupTableHelper } from './BotLookupTableHelper' ; import { BotObjectsContext } from './BotObjectsContext' ; /**
 * Defines an interface for objects that are able to provide the necessary information required to calculate
 * formula values and actions.
 */ export interface BotCalculationContext extends BotObjectsContext { /**
     * The cache that is attached to the context.
     * Useful for saving the results of operations.
     */ cache : Map < string , any > ; /**
     * The lookup table helper that can be used.
     */ lookup : BotLookupTableHelper ; } param name param func param args export function cacheFunction < T > ( calc , name , func , ... args ) { if ( ! calc ) { return func ( ) ; } let key = name ; for ( let arg of args ) { key += `-${ arg }` ; } if ( calc . cache . has ( key ) ) { return calc . cache . get ( key ) ; } const result = func ( ) ; calc . cache . set ( key , result ) ; return result ; }