-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathquery.ts
More file actions
37 lines (33 loc) · 964 Bytes
/
query.ts
File metadata and controls
37 lines (33 loc) · 964 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { FuzzySearcher, PrefixSearcher, SearcherSpec, SubstringSearcher } from './searcher-spec.js';
/**
* Holds the query string and query parameters.
*/
export class Query {
/**
* The query string.
*/
public readonly string: string;
/**
* The maximum number of matches to return. Provide Infinity to return all matches.
*/
public readonly topN: number;
/**
* The searchers to use.
*/
public readonly searchers: SearcherSpec[];
/**
* Creates a new instance of the Query class.
* @param string The query string.
* @param topN The maximum number of matches to return. Provide Infinity to return all matches.
* @param searchers The searchers to use.
*/
public constructor(
string: string,
topN: number = 10,
searchers = [new FuzzySearcher(0.3), new SubstringSearcher(0), new PrefixSearcher(0)]
) {
this.string = string;
this.topN = Math.max(0, topN);
this.searchers = searchers;
}
}