- Docs
String
What @samline/string does, how it splits words and which function to use for each case, slug and text job.
@samline/string converts text between cases, builds URL slugs, searches without accents and shapes text for display, from code or straight from HTML attributes. Every function relies on the same word splitter, so XMLHttpRequest, xml-http-request and xml_http_request always agree.
| Job | Functions |
|---|---|
| Identifiers | camelCase, pascalCase, kebabCase, snakeCase, dotCase, pathCase, constantCase, trainCase |
| Human text | titleCase, sentenceCase, capitalize, uncapitalize |
| URLs and accents | slugify, uniqueSlug, removeAccents, CYRILLIC, GREEK, GERMAN |
| Display | truncate, initials, graphemes, hashColor |
| Text | wordCount, readingTime, pluralize, template, escapeHtml, unescapeHtml, stripTags |
| Search | fold, contains, highlight, compareNatural, distance, similarity, closest |
| Conversions by name | convert, CONVERSIONS, isConversion |
HTML (/vanilla) | data-string, data-string-search, data-string-count, data-string-fit, data-string-copy, data-string-color |
| Building blocks | words |
Choose your next step
Package managers, the CDN and the first slug.
ExamplesLive previews with the complete, copyable source of each one.
API referenceEvery function with examples.
ConfigurationDefaults and accepted values of every function, the HTML layer and locales.
Word splittingExactly how words are detected.
HTML attributesSlug fields, counters, fitted text, copy buttons and avatar colors from data-string-*.
Accent-insensitive matching, highlighting, natural sorting and list filtering.