import { IndexPattern } from './index_pattern' ; export interface PatternCache { get : ( id : string ) => IndexPattern ; set : ( id : string , value : IndexPattern ) => IndexPattern ; clear : ( id : string ) => void ; clearAll : ( ) => void ; } export function createIndexPatternCache ( ) { const vals = { } ; const cache = { get : ( id ) => { return vals [ id ] ; } , set : ( id , prom ) => { vals [ id ] = prom ; return prom ; } , clear : ( id ) => { delete vals [ id ] ; } , clearAll : ( ) => { for ( const id in vals ) { if ( vals . hasOwnProperty ( id ) ) { delete vals [ id ] ; } } } , } ; return cache ; }