From 78cccd21e963939e384ecb520275eedb1197bec9 Mon Sep 17 00:00:00 2001 From: pheralb Date: Wed, 27 Aug 2025 14:36:08 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20Create=20custom=20utili?= =?UTF-8?q?tyusing=20Fuse.js=20for=20efficient=20SVG=20title=20searching?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/searchWithFuse.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/utils/searchWithFuse.ts diff --git a/src/utils/searchWithFuse.ts b/src/utils/searchWithFuse.ts new file mode 100644 index 0000000..af7a844 --- /dev/null +++ b/src/utils/searchWithFuse.ts @@ -0,0 +1,12 @@ +import type { iSVG } from "@/types/svg"; +import Fuse from "fuse.js"; + +export const searchWithFuse = (svgsData: iSVG[]) => { + return new Fuse(svgsData, { + keys: ["title"], + threshold: 0.35, + ignoreLocation: true, + isCaseSensitive: false, + shouldSort: true, + }); +};