import { Tag } from "polar-shared/src/tags/Tags" ; import { arrayStream } from "polar-shared/src/util/ArrayStreams" ; /**
 * We can filter anything that has tags.
 */ export interface ITagged { readonly tags ? : Readonly < { [ id ] : Tag ; } > ; } export namespace TagMatcher2 { param list param filterTags export function filter < T extends ITagged > ( list , filterTags ) { const filterTagsMap = arrayStream ( filterTags ) . toMap ( current => current . id ) ; function predicate ( item ) { const itemTags = Object . values ( item . tags || { } ) ; for ( const itemTag of itemTags ) { if ( filterTagsMap [ itemTag . id ] ) { return true ; } } return false ; } return list . filter ( predicate ) ; } }