@se-oss/slugify
v1.0.0
Published
Blazing fast, strictly typed slugification with Unicode transliteration.
Downloads
53
Maintainers
Readme
@se-oss/slugify is a high-performance, strictly typed slugification library with support for Unicode transliteration, smart casing, and custom character preservation.
📦 Installation
npm install @se-oss/slugifypnpm
pnpm install @se-oss/slugifyyarn
yarn add @se-oss/slugify📖 Usage
Basic
import slugify from '@se-oss/slugify';
slugify('I ♥ Cats');
//=> 'i-love-cats'
slugify(' Déjà Vu! ');
//=> 'deja-vu'
slugify('я люблю единорогов');
//=> 'ya-lyublyu-edinorogov'Advanced Features
- Smart Decamelization: Automatically handles camelCase and PascalCase.
- Character Preservation: Keep specific symbols like
#or@as-is. - Collision Handling: Generate unique slugs using a counter.
- Transliteration: Powered by
@se-oss/transliteratefor robust script support.
import { slugifyWithCounter } from '@se-oss/slugify';
slugify('fooBar 123 $#%', { decamelize: true });
//=> 'foo-bar-123'
const slug = slugifyWithCounter();
slug('foo bar'); //=> 'foo-bar'
slug('foo bar'); //=> 'foo-bar-2'📚 Documentation
For more information, please see the API docs.
🚀 Performance
| Library | hz | min | max | mean | p99 | rme | | :-------------------- | :------------- | :----- | :----- | :----- | :----- | :----- | | @se-oss/slugify | 336,028.90 | 0.0027 | 2.4412 | 0.0030 | 0.0048 | ±0.98% | | simov/slugify | 323,177.82 | 0.0028 | 0.2437 | 0.0031 | 0.0038 | ±0.21% | | @sindresorhus/slugify | 1,936.71 | 0.4814 | 3.0069 | 0.5163 | 0.8098 | ±1.22% |
Result: @se-oss/slugify is 173x faster than @sindresorhus/slugify.
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.
