Options
All
  • Public
  • Public/Protected
  • All
Menu

Module string/distance

Index

Functions String

Functions string

String Functions

  • distance(s1?: string, s2?: string): number
  • calculate distance of two string

    since

    5.16.0

    Parameters

    • s1: string = ""
    • s2: string = ""

    Returns number

string Functions

  • closest(input: string, dict: string[]): string
  • get closest string from dict

    since

    5.16.0

    Parameters

    • input: string
    • dict: string[]
      const dict = ['hello', 'haha', 'mama', 'moment', 'world', 'latest'];

      expect(closest('h', dict)).toBe('haha');
      expect(closest('he', dict)).toBe('hello');
      expect(closest('m', dict)).toBe('mama');
      expect(closest('mo', dict)).toBe('mama');
      expect(closest('mome', dict)).toBe('mama');
      expect(closest('latast', dict)).toBe('latest');

    Returns string