Preparing search index...
    • Performs fuzzy search on an array of items with exact match detection

      Searches for items with values similar to the search query using Fuse.js. First checks for an exact match (case-insensitive), then performs fuzzy matching if no exact match is found. Returns the actual matching items.

      Type Parameters

      • T

      Parameters

      • items: T[]

        Array of items to search

      • searchValue: string

        String to search for

      • getValue: (item: T) => string

        Function to extract searchable string from each item

      • matchLevel: FuzzyMatchLevel

        Semantic matching strictness level

      Returns FuzzySearchResult<T>

      Object containing exact match or similar items

      // Search recipe titles
      const result = fuzzySearch(
      recipes,
      'choclate',
      r => r.title,
      FuzzyMatchLevel.MODERATE
      );

      if (result.exact) {
      console.log('Found exact match:', result.exact.title);
      } else {
      console.log('Found similar recipes:', result.similar);
      }