Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/useFuse.md
1---2category: '@Integrations'3---45# useFuse67Easily implement fuzzy search using a composable with [Fuse.js](https://github.com/krisk/fuse).89From the Fuse.js website:1011> What is fuzzy searching?12>13> Generally speaking, fuzzy searching (more formally known as approximate string matching) is the technique of finding strings that are approximately equal to a given pattern (rather than exactly).1415## Install Fuse.js as a peer dependency1617### NPM1819```bash20npm install fuse.js@^721```2223### Yarn2425```bash26yarn add fuse.js27```2829## Usage3031```ts32import { useFuse } from '@vueuse/integrations/useFuse'33import { shallowRef } from 'vue'3435const data = [36'John Smith',37'John Doe',38'Jane Doe',39'Phillip Green',40'Peter Brown',41]4243const input = shallowRef('Jhon D')4445const { results } = useFuse(input, data)4647/*48* Results:49*50* { "item": "John Doe", "index": 1 }51* { "item": "John Smith", "index": 0 }52* { "item": "Jane Doe", "index": 2 }53*54*/55```5657## Type Declarations5859```ts60export type FuseOptions<T> = IFuseOptions<T>61export interface UseFuseOptions<T> {62fuseOptions?: FuseOptions<T>63resultLimit?: number64matchAllWhenSearchEmpty?: boolean65}66export interface UseFuseReturn<DataItem> {67fuse: Ref<Fuse<DataItem>>68results: ComputedRef<FuseResult<DataItem>[]>69}70export declare function useFuse<DataItem>(71search: MaybeRefOrGetter<string>,72data: MaybeRefOrGetter<DataItem[]>,73options?: MaybeRefOrGetter<UseFuseOptions<DataItem>>,74): UseFuseReturn<DataItem>75```76