Skip to content

Parser Utilities

Parse a raw search string into segments of recognized key:value tokens and plain text.

import { parseTokenizedSearch } from '@requence/tokenized-search'
const segments = parseTokenizedSearch<'status' | 'source'>(
'status:active free text',
['status', 'source'],
)
ParameterTypeDescription
rawTextstringThe raw search query
tokenKeysstring[]Recognized token key names (and labels)

TokenizedSearchSegment[] — array of TokenSegment and TextSegment objects.


Resolve the display text for a token option.

import { getOptionDisplayText } from '@requence/tokenized-search'
const text = getOptionDisplayText({ value: 'active', label: 'Active' })
// → 'Active'
ParameterTypeDescription
optionTokenOptionThe option to resolve

stringoption.label ?? option.value.