Skip to main content
Module

x/cliffy/flags/deps.ts>closestString

Command line framework for deno 🦕 Including Commandline-Interfaces, Prompts, CLI-Table, Arguments Parser and more...
Extremely Popular
Latest
function closestString
import { closestString } from "https://deno.land/x/cliffy@v1.0.0-rc.4/flags/deps.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