Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
didyoumean3
Advanced tools
🚀 The fastest and easiest「didyoumean」in the universe via levenshtein algorithm
npm i didyoumean3
// or
yarn add didyoumean3
import { didyoumean3 } from 'didyoumean3'
// or
const { default: didyoumean3 } = require('didyoumean3');
let input = 'insargrm'
let list = [
'facebook', 'INSTAgram', ' in stagram', 'baidu', 'twitter', 'wechat', 'instagram', 'linkedin'
]
console.log(didyoumean3(input, list));
// will print:
// {
// winner: 'instagram', // 🔥 This is the best match, our winner!
// matched: [
// {
// score: 8,
// target: 'facebook',
// },
// {
// score: 3,
// target: 'instagram',
// },
// {
// score: 7,
// target: 'linkedin',
// },
// // ...
// ],
// }
didyoumea3
has some built-in string formatting configuration items:
ignore
: default is false, Case-insensitivetrim
: default is true, will use string.trim
format the stringtrimAll
: defalut is false, will trim with regexp /\s+/g
diacritics
: default is false, just 'café' -> 'café'.normalize()normalize
: customize the formatting function by yourself🔥If these parameters don't meet your requirements, you can customize the formatting function through normalize
.
🔥When using the custom normalize function, the above string formatting configurations will fail
didyoumean3(input, target, { normalize: (s: string) => s.trim() } );
val
: sometimes, you need to match against a list of object. you can use val
to get the target string out.let input = [
{ id: 'facebook' },
{ id: 'baidu' },
{ id: 'twitter' },
{ id: 'INSTAgram' },
{ id: ' in stagram' },
{ id: 'wechat' },
{ id: 'instagram' },
{ id: 'linkedin' },
];
didyoumean3(input, target, { val: item => item.id } );
result
: Customize the structure of the results you want to return// default result may be null or {winner: xx, matched: []}
type Res = null | { matched: any[], winner: string }
// you can custom your own result style!!
const result = (res: Res) => {
if (!res) return 'nothing matched!'
else return res
}
didyoumean3(input, target, { result } );
filter
: You can filter the results you want, such as those with a score greater than 5let i2 = 'insargrm';
let l2 = ['facebook', 'instagram', 'linkedin'];
expect(
didyoumean3(i2, l2, { filter: (score: number, item: any) => score >= 7 })
?.matched.length
).toBe(2);
didyoumean x 168,623 ops/sec ±0.68% (90 runs sampled)
didyoumean2 x 235,201 ops/sec ±0.51% (92 runs sampled)
didyoumean3 x 398,555 ops/sec ±0.81% (91 runs sampled)
Fastest is didyoumean3
Both issure and pr are welcome!
v-1.2.4
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.
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.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.