import { ITag } from '~/types'; export const separateTags = (tags: Partial[]): Partial[][] => (tags || []).reduce( (obj, tag) => tag?.title?.substr(0, 1) === '/' ? [[...obj[0], tag], obj[1]] : [obj[0], [...obj[1], tag]], [[], []] as Partial[][], ); export const separateTagOptions = (options: string[]): string[][] => separateTags(options.map((title): Partial => ({ title }))).map((item) => item.filter((tag) => tag.title).map(({ title }) => title!), );