jaga-jaga
v2.0.2
Published
A lightweight collection of string manipulation utilities for JavaScript
Maintainers
Readme
Simple String Utils
A lightweight collection of string manipulation utilities for JavaScript with zero dependencies.
Installation
npm install jaga-jagaUsage
const stringUtils = require("jaga-jaga");
// Or import specific functions
const { capitalize, toTitleCase, truncate } = require("jaga-jaga");API Reference
capitalize(str)
Capitalizes the first letter of a string.
stringUtils.capitalize("hello world");
// Returns: 'Hello world'toTitleCase(str)
Converts a string to title case.
stringUtils.toTitleCase("hello world from npm");
// Returns: 'Hello World From Npm'truncate(str, length, suffix)
Truncates a string to a specified length.
stringUtils.truncate("This is a long string", 10);
// Returns: 'This is...'
stringUtils.truncate("This is a long string", 10, "---");
// Returns: 'This i---'toKebabCase(str)
Converts a string to kebab-case.
stringUtils.toKebabCase("Hello World");
// Returns: 'hello-world'
stringUtils.toKebabCase("myVariableName");
// Returns: 'my-variable-name'toCamelCase(str)
Converts a string to camelCase.
stringUtils.toCamelCase("hello world");
// Returns: 'helloWorld'
stringUtils.toCamelCase("my-variable-name");
// Returns: 'myVariableName'wordCount(str)
Counts the number of words in a string.
stringUtils.wordCount("Hello world from npm");
// Returns: 4Examples
const { capitalize, truncate, wordCount } = require("jaga-jaga");
const text = "the quick brown fox jumps over the lazy dog";
console.log(capitalize(text));
// Output: 'The quick brown fox jumps over the lazy dog'
console.log(truncate(text, 20));
// Output: 'the quick brown f...'
console.log(wordCount(text));
// Output: 9License
MIT © Your Name
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
If you find this package helpful, please consider giving it a star on GitHub!
