Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
didyoumean3
Advanced tools
🚀 the super fast and easy didyoumean which use dice-coefficient and levenshtein
notice: Covers most situations and still needs to be optimized, i will do better!
npm i didyoumean3
const didyoumean3 = require('didyoumean3').default
// or if you are using TypeScript or ES module
import didyoumean3 from 'didyoumean3'
let input = 'insargrm'
let list = [
'facebook', 'INSTAgram', ' in stagram', 'baidu', 'twitter', 'wechat', 'instagram', 'linkedin'
]
// levenshtein
didyoumean3(input, list) // instagram
// dice-coefficient
didyoumean3(input, list, { similar: 'dice' }) // instagram
notice: If you customize the algorithm, you must also specify a comparator to indicate whether the output is the smallest or the largest
read more config info 👇
I'm lazy, I just give the declaration file 👇
export interface Val {
(x: string | object): string
}
export interface Similar {
(a: string, b: string, opts?: Partial<Options>): number
}
export interface Return {
(x: any): any
}
export interface Normalize {
(x: string): string
}
// dice-coefficient or levenshtein
export type BuiltInSimilar = 'dice' | 'leven'
/**
* @type {boolean} ignore: ignore case 'A' -> 'a'
* @type {boolean} trim: ' a bcs ' -> 'a bcs'
* @type {boolean} trimAll: ' a bcs' -> 'abcs'
* @type {boolean} diacritics: 'café' -> 'café'.normalize()
* @type {Function} val: when you need find the best result in a object list, it's useful
* @type {string | Function} similar: use builtin shortest edit-distance algorithm or yours
* @type {Function} result: you can custom your return result
* @type {Function} compartor: you can custom the compare rules, because will maybe use the highest score or the lowest score
*/
export type Options = {
ignore?: boolean, // default false
trim?: boolean, // default true
trimAll?: boolean, // default false
diacritics?: boolean, // default false
normalize?: Normalize, // default undefined
val?: Val, // default undefined
similar?: BuiltInSimilar | Similar, // default leven
result?: Return, // default undefined
compartor?: Compartor // default undefined
}
didyoumean x 194,593 ops/sec ±1.07% (84 runs sampled)
didyoumean2 x 311,318 ops/sec ±0.63% (90 runs sampled)
didyoumean3-leven x 510,067 ops/sec ±0.48% (84 runs sampled)
didyoumean3-dice x 294,427 ops/sec ±0.46% (85 runs sampled)
Fastest is didyoumean3-leven
nobody now.
Both issure and pr are welcome!
FAQs
🚀 The fastest and easiest「didyoumean」in the universe via levenshtein algorithm
The npm package didyoumean3 receives a total of 676 weekly downloads. As such, didyoumean3 popularity was classified as not popular.
We found that didyoumean3 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.