1
0
mirror of https://github.com/robonen/tools.git synced 2026-03-20 19:04:46 +00:00

feat(packages): add version jsdoc tags

This commit is contained in:
2024-09-30 06:20:45 +07:00
parent 975ca98f9a
commit 469ef8cdc2
7 changed files with 43 additions and 13 deletions

View File

@@ -4,12 +4,12 @@
* @param {string} left First string
* @param {string} right Second string
* @returns {number} The Levenshtein distance between the two strings
*
* @since 0.0.1
*/
export function levenshteinDistance(left: string, right: string): number {
// If the strings are equal, the distance is 0
if (left === right) return 0;
// If either string is empty, the distance is the length of the other string
if (left.length === 0) return right.length;
if (right.length === 0) return left.length;

View File

@@ -5,6 +5,8 @@ export type Trigrams = Map<string, number>;
*
* @param {string} text The text to extract trigrams
* @returns {Trigrams} A map of trigram to count
*
* @since 0.0.1
*/
export function trigramProfile(text: string): Trigrams {
text = '\n\n' + text + '\n\n';
@@ -26,6 +28,8 @@ export function trigramProfile(text: string): Trigrams {
* @param {Trigrams} left First text trigram profile
* @param {Trigrams} right Second text trigram profile
* @returns {number} The trigram distance between the two strings
*
* @since 0.0.1
*/
export function trigramDistance(left: Trigrams, right: Trigrams): number {
let distance = -4;