@if25b229/string-toolkit
v1.1.0
Published
> A small library that takes a String and converts into either camel-case or kebab-case
Readme
@if25b229/string-toolkit (Self Study B Exercise)
A small library that takes a String and converts into either camel-case or kebab-case
Table of Contents
Installation
Install via npm:
npm install @if25b229/string-toolkitInstall via yarn:
yarn add @if25b229/string-toolkitUsage
Basic Usage
const index = require('./dist/index.cjs');
const toSnakeCase = index.toSnakeCase || index.default || index;
const toKebabCase = index.toKebabCase || index.default || index;
const startString = "HelloWorld";
console.log(toSnakeCase(startString)); // "hello_world"
console.log(toKebabCase(startString)); // "hello-world"Examples
Convert to Snake Case (e.g. for database columns):
const index = require('./dist/index.cjs');
const toSnakeCase = index.toSnakeCase || index.default || index;
const variableName = 'userFirstName';
const formatted = toSnakeCase(variableName);
console.log(formatted); // 'user_first_name'
Convert to Kebab Case (e.g. for URL slugs or CSS classes):
const index = require('./dist/index.cjs');
const toKebabCase = index.toKebabCase || index.default || index;
const title = 'This Is A Great Article';
const slug = toKebabCase(title);
console.log(slug); // 'this-is-a-great-article'Format a sentence for a URL slug:
const index = require('./dist/index.cjs');
const toSnakeCase = index.toSnakeCase || index.default || index;
const title = 'This Is A Great Article';
const slug = toSnakeCase(title);
console.log(slug); // 'this_is_a_great_article'Contribution
Contributions are welcome! Please see CONTRIBUTING.md for more details.
Security
Please refer to our SECURITY.md for information about our security policies, how to report vulnerabilities, and our approach to handling security concerns.
Important Note: This library uses non-cryptographic randomness (Math.random()). Do not rely on it for security-critical functionality.
License
This project is licensed under the MIT License.
