import Group from "../core/Group" ; import Entry from "../core/Entry" ; param groups param compareFn returns export function findEntriesByCheck ( groups , compareFn ) { let foundEntries = [ ] , newEntries ; groups . forEach ( ( group ) => { newEntries = group . getEntries ( ) . filter ( compareFn ) ; if ( newEntries . length > 0 ) { foundEntries = foundEntries . concat ( newEntries ) ; } newEntries = findEntriesByCheck ( group . getGroups ( ) , compareFn ) ; if ( newEntries . length > 0 ) { foundEntries = foundEntries . concat ( newEntries ) ; } } ) ; return foundEntries ; } param groups param compareFn returns export function findGroupsByCheck ( groups , compareFn ) { let foundGroups = groups . filter ( compareFn ) ; groups . forEach ( ( group ) => { const subFound = findGroupsByCheck ( group . getGroups ( ) , compareFn ) ; if ( subFound . length > 0 ) { foundGroups = foundGroups . concat ( subFound ) ; } } ) ; return foundGroups ; } param groups returns export function getAllEntries ( groups ) { return groups . reduce ( ( current , group ) => { const theseEntries = group . getEntries ( ) ; const subEntries = getAllEntries ( group . getGroups ( ) ) ; if ( theseEntries . length > 0 ) { current = current . concat ( theseEntries ) ; } if ( subEntries . length > 0 ) { current = current . concat ( subEntries ) ; } return current ; } , [ ] ) ; }