mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-30 14:57:59 +01:00
3590be1429
* match_query: unit test and rewrite for TypeScript * match_query: use new type for parse errors * match_query: avoid exceptional control flow in date parsing
15 lines
488 B
TypeScript
15 lines
488 B
TypeScript
import { defaultMatcher } from './query/matcher';
|
|
import { generateLexArray } from './query/lex';
|
|
import { parseTokens } from './query/parse';
|
|
import { getAstMatcherForTerm } from './query/term';
|
|
|
|
function parseWithDefaultMatcher(term: string, fuzz: number) {
|
|
return getAstMatcherForTerm(term, fuzz, defaultMatcher);
|
|
}
|
|
|
|
function parseSearch(query: string) {
|
|
const tokens = generateLexArray(query, parseWithDefaultMatcher);
|
|
return parseTokens(tokens);
|
|
}
|
|
|
|
export default parseSearch;
|