Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@types/fast-levenshtein
Advanced tools
TypeScript definitions for fast-levenshtein
@types/fast-levenshtein provides TypeScript type definitions for the fast-levenshtein package, which is a fast implementation of the Levenshtein distance algorithm. This algorithm calculates the edit distance between two strings, which is useful for applications like spell checking, DNA sequencing, and natural language processing.
Calculate Levenshtein Distance
This feature allows you to calculate the Levenshtein distance between two strings. In this example, the distance between 'kitten' and 'sitting' is calculated to be 3.
const levenshtein = require('fast-levenshtein');
const distance = levenshtein.get('kitten', 'sitting');
console.log(distance); // Outputs: 3
Find Closest Match
This feature helps in finding the closest match to a given string from an array of strings. In this example, 'flitting' is the closest match to 'fitting' from the array ['kitten', 'sitting', 'flitting'].
const levenshtein = require('fast-levenshtein');
const words = ['kitten', 'sitting', 'flitting'];
const closest = words.reduce((a, b) => levenshtein.get('fitting', a) < levenshtein.get('fitting', b) ? a : b);
console.log(closest); // Outputs: 'flitting'
The 'levenshtein' package is another implementation of the Levenshtein distance algorithm. It is known for its simplicity and ease of use. Compared to 'fast-levenshtein', it may not be as optimized for performance but is still a reliable choice for calculating edit distances.
The 'js-levenshtein' package is a highly optimized Levenshtein distance algorithm implementation in JavaScript. It is known for its speed and efficiency, making it a strong competitor to 'fast-levenshtein'.
npm install --save @types/fast-levenshtein
This package contains type definitions for fast-levenshtein (https://github.com/hiddentao/fast-levenshtein).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/fast-levenshtein.
export interface LevenshteinOptions {
useCollator?: boolean | undefined;
}
export function get(str1: string, str2: string, opts?: LevenshteinOptions): number;
These definitions were written by Mizunashi Mana.
FAQs
TypeScript definitions for fast-levenshtein
The npm package @types/fast-levenshtein receives a total of 89,438 weekly downloads. As such, @types/fast-levenshtein popularity was classified as popular.
We found that @types/fast-levenshtein 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.