@cripty2001/utils 0.0.118 → 0.0.119
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 +2 -1
- package/dist/Searcher/index.js +14 -4
- package/dist/react-whispr.d.ts +2 -2
- package/dist/react-whispr.js +4 -3
- package/package.json +1 -1
package/dist/Searcher/index.d.ts
CHANGED
|
@@ -7,5 +7,6 @@ export declare class Searcher<T> {
|
|
|
7
7
|
private data;
|
|
8
8
|
constructor(data: SearcherData<T>[]);
|
|
9
9
|
search(query: string): SearcherData<T>[];
|
|
10
|
+
updateData(data: SearcherData<T>[]): void;
|
|
10
11
|
}
|
|
11
|
-
export declare function useSearcher_w<T>(data: SearcherData<T>[]
|
|
12
|
+
export declare function useSearcher_w<T>(data: Whispr<SearcherData<T>[]>, query: Whispr<string>): Whispr<SearcherData<T>[]>;
|
package/dist/Searcher/index.js
CHANGED
|
@@ -13,15 +13,25 @@ class Searcher {
|
|
|
13
13
|
return this.data;
|
|
14
14
|
return this.data.filter(item => item.queries.some(q => q.includes(query.toLowerCase())));
|
|
15
15
|
}
|
|
16
|
+
updateData(data) {
|
|
17
|
+
this.data = data;
|
|
18
|
+
}
|
|
16
19
|
}
|
|
17
20
|
exports.Searcher = Searcher;
|
|
18
21
|
function useSearcher_w(data, query) {
|
|
19
|
-
const searcher = new Searcher(data);
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
const searcher = new Searcher(data.value);
|
|
23
|
+
let unsubscribe_q = () => { };
|
|
24
|
+
let unsubscribe_d = () => { };
|
|
25
|
+
const [toReturn, setToReturn] = whispr_1.Whispr.create([], () => {
|
|
26
|
+
unsubscribe_q();
|
|
27
|
+
unsubscribe_d();
|
|
28
|
+
});
|
|
29
|
+
unsubscribe_q = query.subscribe((q) => {
|
|
23
30
|
let result = searcher.search(q);
|
|
24
31
|
setToReturn(result);
|
|
25
32
|
}, true);
|
|
33
|
+
unsubscribe_d = data.subscribe((d) => {
|
|
34
|
+
searcher.updateData(d);
|
|
35
|
+
}, true);
|
|
26
36
|
return toReturn;
|
|
27
37
|
}
|
package/dist/react-whispr.d.ts
CHANGED
|
@@ -73,8 +73,8 @@ export declare function useAsync<I, O>(f: (input: I, setProgress: (p: number) =>
|
|
|
73
73
|
export declare function useRelTime(refresh?: number): (ts: Date | number) => string;
|
|
74
74
|
/**
|
|
75
75
|
* React shorthand for the Searcher
|
|
76
|
-
* @param data The data to search on
|
|
77
|
-
* @param q The query to search for
|
|
76
|
+
* @param data The data to search on
|
|
77
|
+
* @param q The query to search for
|
|
78
78
|
* @return The filtered data
|
|
79
79
|
*
|
|
80
80
|
*/
|
package/dist/react-whispr.js
CHANGED
|
@@ -177,13 +177,14 @@ function useRelTime(refresh = 1000) {
|
|
|
177
177
|
}
|
|
178
178
|
/**
|
|
179
179
|
* React shorthand for the Searcher
|
|
180
|
-
* @param data The data to search on
|
|
181
|
-
* @param q The query to search for
|
|
180
|
+
* @param data The data to search on
|
|
181
|
+
* @param q The query to search for
|
|
182
182
|
* @return The filtered data
|
|
183
183
|
*
|
|
184
184
|
*/
|
|
185
185
|
function useSearcher(data, q) {
|
|
186
186
|
const q_w = useWhispr(q);
|
|
187
|
-
const
|
|
187
|
+
const data_w = useWhispr(data);
|
|
188
|
+
const searcher = (0, Searcher_1.useSearcher_w)(data_w, q_w);
|
|
188
189
|
return useWhisprValue(searcher);
|
|
189
190
|
}
|
package/package.json
CHANGED