flow import type { FilterType , ListType } from './types' ; export function stringifyFilters ( filters ) { return filters . map ( ( f ) => stringifyFilter ( f ) ) . join ( '; ' ) ; } function stringifyFilter ( filter ) { let spec = 'n/a' ; if ( filter . type === 'list' ) { spec = stringifyListFilter ( filter ) ; } else if ( filter . type === 'picker' ) { spec = filter . spec . selected ; } return JSON . stringify ( { key : filter . key , type : filter . type , enabled : filter . enabled , spec : spec , } ) ; } function stringifyListFilter ( filter ) { let filterValue = filter . spec . selected ; return filterValue . map ( ( f ) => f . title ) . join ( ', ' ) ; }