Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@push.rocks/smartfuzzy

lossless32MIT1.1.10TypeScript support: included

A library for fuzzy matching strings against word dictionaries or arrays, with support for object and article searching.

fuzzy matching, string matching, dictionary matching, search, text analysis, object sorting, article search, text similarity, keyword matching, data filtering

readme

SmartFuzzy Improvement Plan - Fuse.js Optimization Focus

Current Status

  • ESM imports/exports fixed with .js extensions
  • Basic fuzzy matching functionality works
  • Testing infrastructure fixed with @git.zone/tsrun dependency
  • Test syntax standardized using SmartExpect syntax
  • Tests improved with proper assertions and error handling
  • Input validation added to all public methods
  • Code documented with comprehensive TypeScript JSDoc comments
  • Method names standardized for better API consistency
  • Backward compatibility maintained through deprecated method aliases

Improvement Plan - Fuse.js Optimization Focus

1. Fully Leverage Fuse.js Capabilities

1.1 Enhance Configurability

  • <input disabled="" type="checkbox"> Create a comprehensive FuzzyOptions interface exposing Fuse.js options
    • Implementation approach:
      • Expose all relevant Fuse.js options (threshold, distance, location, etc.)
      • Group options logically (matching control, performance control, output control)
      • Add proper TypeScript types and documentation for each option
      • Create sensible defaults for different use cases (loose matching, exact matching, etc.)
      • Add option validation with clear error messages
      • Implement runtime option updates via setOptions() method

1.2 Improve Weighted Field Support

  • <input disabled="" type="checkbox"> Enhance ObjectSorter to support field weights like ArticleSearch
    • Implementation approach:
      • Add ability to specify weight per field in ObjectSorter
      • Maintain backward compatibility with current simple array of fields
      • Create examples of different weighting strategies
      • Add tests demonstrating the effect of different field weights
      • Include weight settings in all relevant documentation

1.3 Add Extended Search Capabilities

  • <input disabled="" type="checkbox"> Implement Fuse.js extended search syntax support
    • Implementation approach:
      • Add support for Fuse.js extended search syntax (AND, OR, exact matching)
      • Create helper methods to build complex search queries
      • Add examples of extended search usage in documentation
      • Create tests for complex search patterns
      • Implement query validation for extended search syntax

2. Performance Optimization

2.1 Optimize Index Creation

  • <input disabled="" type="checkbox"> Implement proper Fuse.js index management
    • Implementation approach:
      • Create persistent indices instead of rebuilding for each search
      • Add incremental index updates when items are added/removed
      • Implement proper index serialization and deserialization
      • Add option to lazily rebuild indices
      • Create tests measuring index creation performance

2.2 Implement Basic Caching

  • <input disabled="" type="checkbox"> Add results caching for repeated queries
    • Implementation approach:
      • Implement simple Map-based cache for query results
      • Add cache invalidation on dictionary/object changes
      • Create configurable cache size limits
      • Add cache hit/miss tracking for debugging
      • Implement optional cache persistence

2.3 Add Async Processing for Large Datasets

  • <input disabled="" type="checkbox"> Implement non-blocking search operations for large datasets
    • Implementation approach:
      • Create async versions of search methods that don't block main thread
      • Implement chunked processing for large dictionaries
      • Add progress tracking for long operations
      • Create cancellable search operations
      • Add proper promise handling and error propagation
      • Measure performance difference between sync and async methods

3. API Improvements

3.1 Standardize Method Naming

  • <input checked="" disabled="" type="checkbox"> Standardize all method names for consistency
    • Implementation completed:
      • Renamed getClosestMatchForString to findClosestMatch
      • Renamed getChangeScoreForString to calculateScores
      • Created backward compatibility aliases with @deprecated tags
      • Updated all tests with new method names
      • ✓ Tests pass and build succeeds

3.2 Add Chainable API

  • <input disabled="" type="checkbox"> Create a more fluent API for complex searches
    • Implementation approach:
      • Implement chainable methods for setting options
      • Add result transformation methods (map, filter, sort)
      • Create fluent search building interface
      • Implement method chaining for filters and transformations
      • Add proper TypeScript type inference for chainable methods
      • Create examples demonstrating the chainable API

3.3 Enhance Return Types

  • <input disabled="" type="checkbox"> Improve result objects with more useful information
    • Implementation approach:
      • Standardize return types across all search methods
      • Add richer match information (character positions, context)
      • Implement highlighting helpers for match visualization
      • Add metadata to search results (time taken, options used)
      • Create proper TypeScript interfaces for all result types

4. Documentation and Examples

4.1 Create Comprehensive Documentation

  • <input disabled="" type="checkbox"> Improve documentation with Fuse.js-specific information
    • Implementation approach:
      • Generate TypeDoc documentation from JSDoc comments
      • Create specific sections for Fuse.js integration details
      • Add visual diagrams showing how Fuse.js is utilized
      • Document all configuration options with examples
      • Add performance guidelines based on Fuse.js recommendations

4.2 Create Usage Examples

  • <input disabled="" type="checkbox"> Add specialized examples for common search patterns
    • Implementation approach:
      • Create examples for typical search scenarios (autocomplete, filtering, etc.)
      • Add examples of weighted searching for different use cases
      • Demonstrate extended search syntax with examples
      • Create comparative examples showing different configuration effects
      • Add performance optimization examples

5. Testing Enhancements

5.1 Add Fuse.js-specific Tests

  • <input disabled="" type="checkbox"> Create tests focused on Fuse.js features
    • Implementation approach:
      • Add tests for all Fuse.js configuration options
      • Create performance comparison tests for different settings
      • Implement tests for extended search syntax
      • Add tests for very large datasets
      • Create index persistence and rebuilding tests

5.2 Add Edge Case Tests

  • <input disabled="" type="checkbox"> Improve test coverage for Fuse.js edge cases
    • Implementation approach:
      • Test with unusual strings (very long, special characters, etc.)
      • Add tests for multilingual content
      • Create tests for zero-match and all-match cases
      • Implement tests for threshold boundary conditions
      • Add tests for unusual scoring scenarios

Implementation Priority

Phase 1: Core Improvements (1-2 weeks)

  • <input checked="" disabled="" type="checkbox"> API Improvements (3.1 Standardize Method Naming) ✓ COMPLETED
  • <input disabled="" type="checkbox"> Configurability Enhancements (1.1 Enhance Configurability)
  • <input disabled="" type="checkbox"> Documentation Updates (4.1 Create Comprehensive Documentation)

Phase 2: Performance Optimizations (1-2 weeks)

  • <input disabled="" type="checkbox"> Optimize Index Creation (2.1)
  • <input disabled="" type="checkbox"> Implement Basic Caching (2.2)
  • <input disabled="" type="checkbox"> Add Fuse.js-specific Tests (5.1)

Phase 3: Advanced Features (2-3 weeks)

  • <input disabled="" type="checkbox"> Improve Weighted Field Support (1.2)
  • <input disabled="" type="checkbox"> Add Extended Search Capabilities (1.3)
  • <input disabled="" type="checkbox"> Add Chainable API (3.2)
  • <input disabled="" type="checkbox"> Enhance Return Types (3.3)
  • <input disabled="" type="checkbox"> Add Async Processing for Large Datasets (2.3)
  • <input disabled="" type="checkbox"> Create Usage Examples (4.2)
  • <input disabled="" type="checkbox"> Add Edge Case Tests (5.2)

Expected Outcomes

  • Significantly improved performance for large datasets
  • More flexible and powerful search capabilities
  • Better developer experience with improved API design
  • Clearer understanding of the library through better documentation
  • Higher test coverage, particularly for edge cases and performance scenarios