@cripty2001/utils 0.0.170 → 0.0.172
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.
package/dist/Searcher/index.d.ts
CHANGED
|
@@ -5,6 +5,6 @@ export type SearcherData<T> = {
|
|
|
5
5
|
export declare class Searcher<T> {
|
|
6
6
|
private data;
|
|
7
7
|
constructor(data: SearcherData<T>[]);
|
|
8
|
-
search(query: string): SearcherData<T>[];
|
|
8
|
+
search(query: string, limit?: number): SearcherData<T>[];
|
|
9
9
|
updateData(data: SearcherData<T>[]): void;
|
|
10
10
|
}
|
package/dist/Searcher/index.js
CHANGED
|
@@ -6,10 +6,12 @@ class Searcher {
|
|
|
6
6
|
constructor(data) {
|
|
7
7
|
this.data = data;
|
|
8
8
|
}
|
|
9
|
-
search(query) {
|
|
9
|
+
search(query, limit = 10) {
|
|
10
10
|
if (query === "")
|
|
11
11
|
return this.data;
|
|
12
|
-
return this.data
|
|
12
|
+
return this.data
|
|
13
|
+
.filter(item => item.queries.some(q => q.includes(query.toLowerCase())))
|
|
14
|
+
.slice(0, limit);
|
|
13
15
|
}
|
|
14
16
|
updateData(data) {
|
|
15
17
|
this.data = data;
|
package/dist/react-whispr.d.ts
CHANGED
|
@@ -125,7 +125,7 @@ export declare function useRelTime(_data: number | Date): string;
|
|
|
125
125
|
* - The filtered data
|
|
126
126
|
* - A boolean indicating if the search is pending
|
|
127
127
|
*/
|
|
128
|
-
export declare function useSearcher<T extends JSONEncodable>(data: SearcherData<T>[]): [string, (q: string) => void, SearcherData<T>[], boolean];
|
|
128
|
+
export declare function useSearcher<T extends JSONEncodable>(data: SearcherData<T>[], limit?: number): [string, (q: string) => void, SearcherData<T>[], boolean];
|
|
129
129
|
/**
|
|
130
130
|
* A react ref hook with safe lazy initialization, ready for safe side effects.
|
|
131
131
|
* @remarks The initialization function will only be called once, and the result will be stored in the ref.
|
package/dist/react-whispr.js
CHANGED
|
@@ -280,7 +280,7 @@ function getRelTimeFormat(_diff) {
|
|
|
280
280
|
* - The filtered data
|
|
281
281
|
* - A boolean indicating if the search is pending
|
|
282
282
|
*/
|
|
283
|
-
function useSearcher(data) {
|
|
283
|
+
function useSearcher(data, limit = 10) {
|
|
284
284
|
const [pending, setPending] = (0, react_1.useState)(false);
|
|
285
285
|
const [results, setResults] = (0, react_1.useState)({
|
|
286
286
|
results: [],
|
|
@@ -295,7 +295,7 @@ function useSearcher(data) {
|
|
|
295
295
|
}, [data]);
|
|
296
296
|
const [q, setQ] = useAsyncInput(results, setResults, async ({ q }) => {
|
|
297
297
|
return {
|
|
298
|
-
results: searcher.current.search(q)
|
|
298
|
+
results: searcher.current.search(q, limit)
|
|
299
299
|
};
|
|
300
300
|
}, setPending);
|
|
301
301
|
return [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cripty2001/utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.172",
|
|
4
4
|
"description": "Internal Set of utils. If you need them use them, otherwise go to the next package ;)",
|
|
5
5
|
"homepage": "https://github.com/cripty2001/utils#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@cripty2001/whispr": "^0.
|
|
25
|
+
"@cripty2001/whispr": "^0.4.1",
|
|
26
26
|
"lodash": "^4.17.21"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
@@ -91,4 +91,4 @@
|
|
|
91
91
|
"types": "./dist/react-ui/index.d.ts"
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
}
|
|
94
|
+
}
|