mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 12:33:03 +00:00
19 lines
538 B
TypeScript
19 lines
538 B
TypeScript
import { useFuse } from "@vueuse/integrations/useFuse";
|
|
import { Ref } from "vue";
|
|
|
|
/**
|
|
* Fuzzy search using Fuse.js
|
|
* @param query The query to search for
|
|
* @param data The list to search in
|
|
* @param fuseOptions Fuse.js options
|
|
* @returns A ref containing the search results
|
|
*/
|
|
export default (query: string, data: any[], fuseOptions: object) => {
|
|
const { results } = useFuse(query, data, {
|
|
matchAllWhenSearchEmpty: true,
|
|
fuseOptions: { ...fuseOptions, threshold: 0.3, ignoreLocation: true },
|
|
});
|
|
|
|
return results;
|
|
};
|