Gathering detailed insights and metrics for didyoumean2
Gathering detailed insights and metrics for didyoumean2
Gathering detailed insights and metrics for didyoumean2
Gathering detailed insights and metrics for didyoumean2
a library for matching human-quality input to a list of potential matches using the Levenshtein distance algorithm
npm install didyoumean2
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
100 Stars
1,713 Commits
5 Forks
6 Watching
8 Branches
6 Contributors
Updated on 28 Nov 2024
TypeScript (96.91%)
JavaScript (3.09%)
Cumulative downloads
Total Downloads
Last day
-13.7%
23,142
Compared to previous day
Last week
-0.2%
136,588
Compared to previous week
Last month
1%
628,484
Compared to previous month
Last year
32.3%
6,418,622
Compared to previous year
3
29
didyoumean2
is a library for matching human-quality input to a list of potential matches using the Levenshtein distance algorithm.
It is inspired by didyoumean.js.
Based on fastest-levenshtein, the fastest JS implementation of the Levenshtein distance algorithm
~100% faster than didyoumean.js
Well tested with 100% coverage
Static type checking with TypeScript
More control on what kind of matches you want to return
Support matching object's path
instead of just key
1npm install didyoumean2
1const didYouMean = require('didyoumean2').default 2// or if you are using TypeScript or ES module 3import didYouMean from 'didyoumean2' 4 5// you can also access to Enums via: 6const { 7 default: didYouMean, 8 ReturnTypeEnums, 9 ThresholdTypeEnums, 10} = require('didyoumean2') 11// or 12import didYouMean, { ReturnTypeEnums, ThresholdTypeEnums } from 'didyoumean2'
We are using corepack to manage the yarn
version
1corepack enable
1didYouMean(input, matchList[, options])
input {string}
: A string that you are not sure and want to match with matchList
matchList {Object[]|string[]}
: A List for matching with input
options {Object}
(optional): An options that allows you to modify the behavior
@return {Array|null|Object|string}
: A list of or single matched result(s), return object if match
is {Object[]}
caseSensitive {boolean}
default: false
Perform case-sensitive matching
deburr {boolean}
default: true
Perform combining diacritical marks insensitive matching
Refer to lodash _.deburr for how it works
matchPath {Array}
default: []
If your matchList
is an array of object, you must use matchPath
to point to the string that you want to match
Refer to ramda R.path for how to define the path, e.g. ['obj', 'array', 0, 'key']
returnType {string}
ReturnTypeEnums.FIRST_CLOSEST_MATCH
returnType | Description |
---|---|
ReturnTypeEnums.ALL_CLOSEST_MATCHES | Return all matches with the closest value to the input in array |
ReturnTypeEnums.ALL_MATCHES | Return all matches in array |
ReturnTypeEnums.ALL_SORTED_MATCHES | Return all matches in array, sorted from closest to furthest |
ReturnTypeEnums.FIRST_CLOSEST_MATCH | Return first match from ReturnTypeEnums.ALL_CLOSEST_MATCHES |
ReturnTypeEnums.FIRST_MATCH | Return first match (FASTEST) |
threshold {integer|number}
depends on thresholdType
type: {number}
(similarity
) or {integer}
(edit-distance
)
default: 0.4
(similarity
) or 20
(edit-distance
)
If the result is larger (similarity
) or smaller (edit-distance
) than or equal to the threshold
, that result is matched
thresholdType {string}
ThresholdTypeEnums.SIMILARITY
thresholdType | Description |
---|---|
ThresholdTypeEnums.EDIT_DISTANCE | Refer to Levenshtein distance algorithm, must be integer , lower value means more similar |
ThresholdTypeEnums.SIMILARITY | l = max(input.length, matchItem.length), similarity = (l - editDistance) / l , number from 0 to 1 , higher value means more similar |
trimSpaces {boolean}
default: true
Remove noises when matching
Trim all starting and ending spaces, and concatenate all continuous spaces to one space
Before all:
1npm install -g yarn 2yarn install
Unit test and coverage:
1yarn test
Linter:
1yarn lint
No vulnerabilities found.
Reason
30 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
3 existing vulnerabilities detected
Details
Reason
Found 0/29 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More