No description
Find a file
Lilith b474577ff3 chore(gitignore): Add missing patterns
Patterns added: dist/
2026-01-21 15:42:17 -08:00
.forgejo/workflows chore: initial commit 2026-01-21 11:37:28 -08:00
.turbo chore: initial commit 2026-01-21 11:37:28 -08:00
dist chore(gitignore): Add missing patterns 2026-01-21 15:42:17 -08:00
node_modules chore(gitignore): Add missing patterns 2026-01-21 15:42:17 -08:00
src chore: initial commit 2026-01-21 11:37:28 -08:00
.gitignore chore(gitignore): Add missing patterns 2026-01-21 15:42:17 -08:00
COMMIT_HISTORY.md chore: initial commit 2026-01-21 11:37:28 -08:00
eslint.config.js chore: initial commit 2026-01-21 11:37:28 -08:00
package.json deps-upgrade: ⬆️ Update core dependencies to latest stable versions for security, compatibility, and performance improvements 2026-01-21 15:25:57 -08:00
package.json.tmp chore: initial commit 2026-01-21 11:37:28 -08:00
README.md chore: initial commit 2026-01-21 11:37:28 -08:00
tsconfig.json chore: initial commit 2026-01-21 11:37:28 -08:00
tsup.config.ts chore(build): Optimize TypeScript build with ESM output and minification in tsup config 2026-01-21 15:25:57 -08:00
vitest.config.ts chore: initial commit 2026-01-21 11:37:28 -08:00

@uwuapps/algorithms

High-performance algorithms for text processing and data structures.

Installation

npm install @uwuapps/algorithms

Features

Distance Algorithms

  • Levenshtein Distance: Classic edit distance algorithm
  • Optimized Levenshtein: Space-optimized O(min(n,m)) implementation
  • Damerau-Levenshtein: Includes transpositions for better typo detection

Phonetic Algorithms

  • Soundex: Classic phonetic encoding
  • Metaphone: Improved English pronunciation rules
  • Double Metaphone: Handles multiple pronunciations

Data Structures

  • Trie: Efficient prefix tree with frequency tracking

Usage

Distance Algorithms

import { LevenshteinDistance, DamerauLevenshtein } from '@uwuapps/algorithms/distance';

const levenshtein = new LevenshteinDistance();
const distance = levenshtein.calculate('hello', 'hallo'); // 1
const similarity = levenshtein.similarity('hello', 'hallo'); // 0.8

const damerau = new DamerauLevenshtein();
const typoDistance = damerau.calculate('teh', 'the'); // 1 (transposition)

Phonetic Algorithms

import { Soundex, Metaphone } from '@uwuapps/algorithms/phonetic';

const soundex = new Soundex();
const code = soundex.encode('Smith'); // S530
const soundsLike = soundex.soundsLike('Smith', 'Smythe'); // true

const metaphone = new Metaphone();
const phoneticCode = metaphone.encode('phone'); // FN

Data Structures

import { Trie } from '@uwuapps/algorithms/data-structures';

const trie = new Trie();
trie.insert('hello', 10);
trie.insert('help', 5);

const suggestions = trie.getSuggestions('hel'); // ['hello', 'help']
const exists = trie.search('hello'); // true

Performance

All algorithms are optimized for performance:

  • Caching for repeated calculations
  • Early termination with max distance
  • Space-optimized implementations
  • Efficient data structures

License

MIT