@itreg/string-toolkit
v1.1.0
Published
Simple string manipulation utilities
Maintainers
Readme
@itreg/string-toolkit
A lightweight JavaScript utility library for simple and consistent string case transformations.
Supports conversion to snake_case and kebab-case.
Installation
npm
npm install @itreg/string-toolkityarn
yarn add @itreg/string-toolkitUsage
const { toSnakeCase, toKebabCase } = require("@itreg/string-toolkit");API
toSnakeCase(string)
Converts a string into snake_case (lowercase words separated by underscores).
Example:
toSnakeCase("Hello World");
// "hello_world"Behavior:
- Trims leading/trailing whitespace
- Converts all characters to lowercase
- Replaces spaces and hyphens with underscores
- Removes unsupported special characters
toKebabCase(string)
Converts a string into kebab-case (lowercase words separated by dashes).
Example:
toKebabCase("Hello World");
// "hello-world"Behavior:
- Trims leading/trailing whitespace
- Converts all characters to lowercase
- Replaces spaces and underscores with dashes
- Removes unsupported special characters
Development
Install dependencies
npm installRun tests
npm testTesting
This project uses Jest for unit testing.
Example tests:
const { toSnakeCase, toKebabCase } = require("../src");
test("converts string to snake_case", () => {
expect(toSnakeCase("Hello World")).toBe("hello_world");
});
test("converts string to kebab-case", () => {
expect(toKebabCase("Hello World")).toBe("hello-world");
});Project Structure
string-toolkit/
├── src/
├── tests/
├── package.json
├── README.mdContributing
Contributions are welcome.
Basic workflow:
- Fork the repository
- Create a feature branch (
git checkout -b feature/your-feature) - Commit your changes
- Push to your fork
- Open a Pull Request
Please follow the templates provided in the repository for issues and pull requests.
Security
If you discover a vulnerability, please report it according to the instructions in SECURITY.md.
License
This project is licensed under the MIT License. See LICENSE.md for details.
