import { SandDance } from '@msrvida/sanddance-react' ; import SearchExpressionGroup = SandDance . searchExpression . SearchExpressionGroup ; function comparableGroup ( group ) { return { ... group , clause : null } ; } function compareGroup ( a , b ) { return SandDance . searchExpression . compareGroup ( comparableGroup ( a ) , comparableGroup ( b ) ) ; } export function toggleSearch ( haystack , needle ) { const groups = [ ] ; let found = false ; haystack . forEach ( group => { if ( compareGroup ( group , needle ) ) { found = true ; } else { groups . push ( group ) ; } } ) ; return { groups , found } ; }