Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@types/js-levenshtein
Advanced tools
TypeScript definitions for js-levenshtein
The @types/js-levenshtein package provides TypeScript type definitions for the js-levenshtein package, which is an efficient JavaScript implementation of the Levenshtein algorithm. This algorithm calculates the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one word into another. The type definitions enable TypeScript developers to use js-levenshtein in their projects with type checking, ensuring that they pass the correct types of arguments to the functions and use the returned values as expected.
Calculating Levenshtein Distance
This feature allows you to calculate the Levenshtein distance between two strings, which is the minimum number of single-character edits required to change one string into the other. The code sample demonstrates how to import the levenshtein function and use it to calculate the distance between 'kitten' and 'sitting', which is 3.
import levenshtein from 'js-levenshtein';
const distance = levenshtein('kitten', 'sitting');
console.log(distance); // Output: 3
The fast-levenshtein package is another JavaScript implementation of the Levenshtein distance algorithm. It claims to be the fastest JS implementation of the algorithm. Compared to js-levenshtein, fast-levenshtein might offer better performance in some scenarios, but both provide similar basic functionality of calculating the Levenshtein distance.
levenshtein-edit-distance is a package that also calculates the Levenshtein distance between two strings. It focuses on being a simple and small implementation. While js-levenshtein and fast-levenshtein might be optimized for performance, levenshtein-edit-distance offers a minimalistic approach which might be preferable for projects where bundle size is a concern.
npm install --save @types/js-levenshtein
This package contains type definitions for js-levenshtein (https://github.com/gustf/js-levenshtein).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/js-levenshtein.
/**
* Calculates Levenshtein distance between two strings
*/
declare function levenshtein(compareFrom: string, compareTo: string): number;
export = levenshtein;
These definitions were written by Pyry Rouvila.
FAQs
TypeScript definitions for js-levenshtein
The npm package @types/js-levenshtein receives a total of 434,527 weekly downloads. As such, @types/js-levenshtein popularity was classified as popular.
We found that @types/js-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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.