import { IndexPatternProvider } from '../types' ; import { IndexPattern } from '../../../../../src/plugins/data/public' ; export function createCachedIndexPatternProvider ( indexPatternGetter ) { const cache = new Map < string , IndexPattern > ( ) ; return { get : async ( id ) => { if ( ! cache . has ( id ) ) { cache . set ( id , await indexPatternGetter ( id ) ) ; } return Promise . resolve ( cache . get ( id ) ! ) ; } , } ; }