npm.io
1.0.0 • Published 3d ago

tiny-string-utils

Licence
MIT
Version
1.0.0
Deps
0
Size
17 kB
Vulns
0
Weekly
0

tiny-string-utils

A lightweight, zero-dependency library for common string manipulations.

Installation

npm install tiny-string-utils

Usage

import { capitalize, slugify, camelCase, truncate } from 'tiny-string-utils';

capitalize('hello');         // 'Hello'
slugify('Hello World!');     // 'hello-world'
camelCase('foo-bar-baz');    // 'fooBarBaz'
truncate('Long text...', 8); // 'Long...'

Available Functions

  • capitalize(str) — Capitalize the first letter
  • slugify(str) — Convert to URL-friendly slug
  • truncate(str, length, suffix?) — Truncate with suffix
  • camelCase(str) — Convert to camelCase
  • kebabCase(str) — Convert to kebab-case
  • snakeCase(str) — Convert to snake_case
  • reverse(str) — Reverse a string
  • countWords(str) — Count words
  • stripWhitespace(str) — Remove all whitespace
  • isPalindrome(str) — Check if palindrome
  • padCenter(str, length, char?) — Center-pad a string
  • repeat(str, count, separator?) — Repeat a string

Keywords