mirror of
https://github.com/Kaelio/ktx.git
synced 2026-07-01 08:59:39 +02:00
Initial open-source release
This commit is contained in:
commit
1a42152e6f
1199 changed files with 257054 additions and 0 deletions
19
packages/context/src/search/query.ts
Normal file
19
packages/context/src/search/query.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import type { NormalizedSearchQuery } from './types.js';
|
||||
|
||||
export function normalizeSearchQuery(queryText: string): NormalizedSearchQuery {
|
||||
const terms = queryText
|
||||
.toLowerCase()
|
||||
.split(/[^a-z0-9_]+/u)
|
||||
.map((term) => term.trim())
|
||||
.filter(Boolean);
|
||||
|
||||
return {
|
||||
raw: queryText,
|
||||
normalized: terms.join(' '),
|
||||
terms,
|
||||
};
|
||||
}
|
||||
|
||||
export function defaultLaneCandidatePoolLimit(finalLimit: number): number {
|
||||
return Math.max(25, Math.max(1, finalLimit) * 3);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue