@ende/text
ende add jsr:@ende/textVersion 2026.10.15 on JSR.
Utility functions for working with text.
import { toCamelCase, compareSimilarity } from "@ende/text";
import { assertEquals } from "@ende/assert";
assertEquals(toCamelCase("snake_case"), "snakeCase");
const words = ["hi", "help", "hello"];
// Words most similar to "hep" will be at the front
assertEquals(words.sort(compareSimilarity("hep")), ["help", "hi", "hello"]);
Modules
@ende/text/closest-string@ende/text/compare-similarity@ende/text/levenshtein-distance@ende/text/to-camel-case@ende/text/to-kebab-case@ende/text/to-pascal-case@ende/text/to-snake-case@ende/text/truncate@ende/text/unstable-dedent@ende/text/unstable-longest-common-prefix@ende/text/unstable-reverse@ende/text/unstable-slugify@ende/text/unstable-to-constant-case@ende/text/unstable-to-sentence-case@ende/text/unstable-to-title-case@ende/text/unstable-trim-by@ende/text/word-similarity-sort
Exports
closestString— Finds the most similar string from an array of strings.ClosestStringOptions— Options for closestString.compareSimilarity— Takes a string and generates a comparator function to determine which of two strings is more similar to the given one.CompareSimilarityOptions— Options for compareSimilarity.levenshteinDistance— Calculates the Levenshtein distance between two strings.toCamelCase— Converts a string into camelCase.toKebabCase— Converts a string into kebab-case.toPascalCase— Converts a string into PascalCase.toSnakeCase— Converts a string into snake_case.truncate— Truncates a string to at most `maxLength` UTF-16 code units. When truncation occurs the suffix is included within the `maxLength` budget. Surrogate pairs are never split, so the result may be shorter than `maxLength` when a cut would land inside a pair. When the suffix itself contains surrogate pairs and `maxLength` is very small, the result can even be empty.TruncateOptions— Options for truncate.wordSimilaritySort— Sorts a string-array by similarity to a given string.WordSimilaritySortOptions— Options for wordSimilaritySort.