export interface Data { key : string ; label : string ; level : number ; path : string ; } class HeadingStore { store : { [ key ] : Data ; } = { } ; headings : { [ key ] : Data [ ] ; } = { } ; add ( key , data ) { console . log ( 'add being called with' , data . label ) ; if ( ! this . headings [ location . pathname ] ) { this . headings [ location . pathname ] = [ ] ; } if ( ! this . store [ key ] ) { this . store [ key ] = data ; this . headings [ location . pathname ] . push ( data ) ; } } getStore ( ) { return this . store ; } getPageHeadings ( page ) { return this . headings [ page ] ; } getAllHeadings ( ) { return this . headings ; } getHeadingByKey ( key ) { return this . store [ key ] ; } } const store = new HeadingStore ( ) ; export default store ;