A lightweight library for string formatting and transformation, built in TypeScript. It provides various utilities for manipulating string cases, formatting strings, and more.
- Convert strings between camelCase, PascalCase, snake_case, kebab-case, and other formats.
- Slugify strings for URL-friendly output.
- Template string replacement for dynamic content.
- Easily extensible with more string transformation methods.
You can install @tyecode/strman
via npm
, yarn
or pnpm
:
# Using npm
npm install @tyecode/strman
# Using yarn
yarn add @tyecode/strman
# Using pnpm
pnpm add @tyecode/strman
Import the functions you need from the package:
import { toCamelCase, toPascalCase, toSnakeCase, toKebabCase, capitalize, slugify, templateReplace } from '@tyecode/strman';
console.log(toCamelCase('hello_world')); // helloWorld
console.log(toPascalCase('hello_world')); // HelloWorld
console.log(toSnakeCase('HelloWorld')); // hello_world
console.log(toKebabCase('HelloWorld')); // hello-world
console.log(capitalize('hello')); // Hello
console.log(slugify('Hello World!')); // hello-world
console.log(templateReplace('Hello {name}!', { name: 'Tye' })); // Hello Tye!
Converts a string to camelCase.
Converts a string to PascalCase.
Converts a string to snake_case.
Converts a string to kebab-case.
Capitalizes the first letter of the string.
Converts a string to a slug format (lowercase and hyphen-separated).
Replaces placeholders in the template string with values from the provided object.
-
Clone the repository:
git clone https://github.com/tyecode/strman.git cd strman
-
Install dependencies:
pnpm install
-
Build the project:
pnpm run build
-
Run tests:
pnpm run test
To lint the project:
pnpm run lint
- Fork the repository.
- Create a new branch (
git checkout -b feature-name
). - Make your changes.
- Commit your changes (
git commit -am 'Add feature'
). - Push to the branch (
git push origin feature-name
). - Create a new Pull Request.
MIT License. See LICENSE for more information.