Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

didyoumean

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

didyoumean

Match human-quality input to potential matches by edit distance.

  • 1.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is didyoumean?

The didyoumean npm package is designed to help find the best match for a given string from a list of strings. It's commonly used for suggesting corrections for typos or misspelled words in user input, making it a valuable tool for improving user experience in applications that involve text input.

What are didyoumean's main functionalities?

String Matching

This feature allows you to match a given input string against a list of strings and find the closest match. It's useful for suggesting corrections for misspelled words.

"use strict";
const didYouMean = require('didyoumean');

// List of strings to match against
const list = ['apple', 'banana', 'orange', 'grapes'];

// The string to match
const input = 'aple';

// Find the best match
const match = didYouMean(input, list);

console.log(match); // 'apple'

Case Sensitivity

This feature demonstrates how to toggle case sensitivity. By default, didyoumean is case-sensitive, but you can turn off case sensitivity to broaden the matching criteria.

"use strict";
const didYouMean = require('didyoumean');
didYouMean.caseSensitive = false; // Turn off case sensitivity

// List of strings to match against
const list = ['Apple', 'Banana', 'Orange', 'Grapes'];

// The string to match
const input = 'apple';

// Find the best match
const match = didYouMean(input, list);

console.log(match); // 'Apple'

Threshold for Matches

This feature allows you to set a threshold for how close the match needs to be. The threshold is a number between 0 and 1, where 1 means the match must be exact, and 0 means any match is acceptable.

"use strict";
const didYouMean = require('didyoumean');

// Set the threshold for match quality (0 to 1)
didYouMean.threshold = 0.4;

// List of strings to match against
const list = ['apple', 'banana', 'orange', 'grapes'];

// The string to match
const input = 'aple';

// Find the best match
const match = didYouMean(input, list);

console.log(match); // 'apple'

Other packages similar to didyoumean

Keywords

FAQs

Package last updated on 24 Jun 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc