UNPKG

nhb-toolbox

Version:

A versatile collection of smart, efficient, and reusable utility functions, classes and types for everyday development needs.

29 lines (28 loc) 1.26 kB
/** * * Extracts all numbers from a string as array of numbers. * @param input - The string to extract numbers from. * @returns An array of numbers found in the string. */ export declare const extractNumbersFromString: (input: string) => number[]; /** * * Computes the Levenshtein distance between two strings (space optimized). * @param str1 - First string to compare. * @param str2 - Second string to compare. * @returns The Levenshtein distance between the two strings. * * @remarks * - The Levenshtein distance is the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one string into the other. * - This implementation uses only O(min(len(a), len(b))) space by keeping only the current and previous rows of the distance matrix. * * @example * const distance = getLevenshteinDistance('kitten', 'sitting'); * console.log(distance); // Output: 3 */ export declare const getLevenshteinDistance: (str1: string, str2: string) => number; /** * * Counts the number of words in a string, supporting multiple languages and scripts. * * @param text - The input string to count words from. * @returns Number of words (Unicode-aware). */ export declare function countWords(text: string): number;