@se-oss/transliterate
v1.0.0
Published
High-performance, strictly typed transliteration library with support for Unicode normalization, smart casing, and multiple scripts.
Maintainers
Readme
@se-oss/transliterate is a high-performance, strictly typed transliteration library that handles Unicode normalization, smart casing, and multiple scripts with ease.
📦 Installation
npm install @se-oss/transliteratepnpm
pnpm install @se-oss/transliterateyarn
yarn add @se-oss/transliterate📖 Usage
Basic
import transliterate from '@se-oss/transliterate';
transliterate('Я люблю единорогов');
//=> 'Ya lyublyu edinorogov'Advanced Features
- Smart Casing: Handles multi-character replacements (e.g.,
ЦАРЬ→TSAR). - Locale Overrides: Supports language-specific rules (e.g., German
ä→ae). - Functional Replacers: Use functions for dynamic custom replacements.
- Strict ASCII: Option to strip any remaining non-ASCII characters.
transliterate('Fußgängerübergänge', { locale: 'de' });
//=> 'Fussgaengeruebergaenge'
transliterate('hello', {
customReplacements: [['hello', (match) => match.toUpperCase()]],
});
//=> 'HELLO'📚 Documentation
For more information, please see the API docs.
🚀 Performance
| Library | hz | min | max | mean | p99 | rme | | :-------------------------- | :------------- | :----- | :----- | :----- | :----- | :----- | | @se-oss/transliterate | 411,035.42 | 0.0022 | 0.5687 | 0.0024 | 0.0039 | ±0.35% | | transliteration | 413,918.42 | 0.0020 | 3.7193 | 0.0024 | 0.0043 | ±1.47% | | @sindresorhus/transliterate | 275,554.28 | 0.0030 | 0.5995 | 0.0036 | 0.0063 | ±0.37% |
Result: @se-oss/transliterate is 1.49x faster than @sindresorhus/transliterate.
Benchmark script: bench/index.bench.ts
🤝 Contributing
Want to contribute? Awesome! To show your support is to star the project, or to raise issues on GitHub.
Thanks again for your support, it is much appreciated! 🙏
License
MIT © Shahrad Elahi and contributors.
