import Group from "../core/Group" ; import { GroupID } from "../types" ; param groups param title returns export function findGroupsByTitle ( groups , title ) { return groups . filter ( group => { if ( title instanceof RegExp ) { return title . test ( group . getTitle ( ) ) ; } return group . getTitle ( ) . indexOf ( title ) >= 0 ; } ) ; } export function getAllChildGroups ( groups , parentID ) { if ( parentID === "0" ) return [ ... groups ] ; const getParentID = ( g ) => g . vault . format . getItemParentID ( g . _source ) ; return groups . filter ( group => { const thisParentID = getParentID ( group ) ; if ( thisParentID === parentID ) return true ; let nextParent ; while ( ( nextParent = nextParent ? nextParent . getParentGroup ( ) : group . getParentGroup ( ) ) !== null ) { if ( nextParent . id === parentID ) return true ; } return false ; } ) ; }