Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

std/text/mod.ts>closestString

The Deno Standard Library
Latest
function closestString
import { closestString } from "https://deno.land/std@0.224.0/text/mod.ts";

get most-similar word

Examples

Example 1

import { closestString } from "https://deno.land/std@0.224.0/text/closest_string.ts";

const possibleWords: string[] = ["length", "size", "blah", "help"];

// case-insensitive by default
const word = closestString("hep", possibleWords);

Parameters

givenWord: string
  • The string to measure distance against
possibleWords: string[]
  • The string-array that will be sorted
optional
options: { caseSensitive?: boolean; }
  • Flag indicating whether the distance should include case. Default is false.

Returns

string

A sorted copy of possibleWords