highlight-words 1.2.2-beta.0 → 1.2.2-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,34 @@
1
+ declare namespace HighlightWords {
2
+ interface Chunk {
3
+ key: string;
4
+ text: string;
5
+ match: boolean;
6
+ }
7
+ interface Options {
8
+ text: string;
9
+ query: string;
10
+ clipBy?: number;
11
+ matchExactly?: boolean;
12
+ }
13
+ interface Clip {
14
+ curr: Chunk;
15
+ next?: Chunk;
16
+ prev?: Chunk;
17
+ clipBy?: number;
18
+ }
19
+ interface Query {
20
+ terms: string;
21
+ matchExactly?: boolean;
22
+ }
23
+ }
24
+
25
+ /**
26
+ * Split a text into chunks denoting which are a match and which are not based on a user search term.
27
+ * @param text String The text to split.
28
+ * @param query String The query to split by. This can contain multiple words.
29
+ * @param clipBy Number Clip the non-matches by a certain number of words to provide context around the matches.
30
+ * @param matchExactly Boolean If we have multiple words in the query, we will match any of the words if exact is false. For example, searching for "brown fox" in "the brown cute fox" will yield both "brown" and "fox" as matches. While if exact is true, the same search will return no results.
31
+ */
32
+ declare const highlightWords: ({ text, query, clipBy, matchExactly }: Readonly<HighlightWords.Options>) => HighlightWords.Chunk[];
33
+
34
+ export { HighlightWords, highlightWords as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "highlight-words",
3
- "version": "1.2.2-beta.0",
3
+ "version": "1.2.2-beta.1",
4
4
  "description": "Split a piece text into multiple chunks based on a search query, allowing you to highlight the matches.",
5
5
  "engines": {
6
6
  "node": ">= 16",
@@ -36,7 +36,6 @@
36
36
  "module": "dist/highlight-words.mjs",
37
37
  "exports": {
38
38
  ".": {
39
- "types": "./dist/highlight-words.d.ts",
40
39
  "require": "./dist/highlight-words.js",
41
40
  "default": "./dist/highlight-words.mjs"
42
41
  }