MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / fuzzySearch

Function fuzzySearch

packages/core/ui/styling/font-common.ts:209–230  ·  view source on GitHub ↗
(query: string, dataset: string[])

Source from the content-addressed store, hash-verified

207 * but tags are the standards.
208 */
209export function fuzzySearch(query: string, dataset: string[]): string[] | null {
210 const q = query ? query.trim().toLowerCase() : '';
211
212 const result: string[] = [];
213 if (!q.length) {
214 return null;
215 }
216
217 dataset.forEach((item) => {
218 const s = item.trim().toLowerCase();
219 let n = -1;
220 for (const char of q) {
221 n = s.indexOf(char, n + 1);
222 if (!~n) {
223 return;
224 }
225 }
226 result.push(item);
227 });
228
229 return result.length ? result : null;
230}

Callers 1

getUIFontCachedFunction · 0.90

Calls 3

forEachMethod · 0.80
indexOfMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected