stringemperor
v1.0.1
Published
String utility package to play around with strings.
Maintainers
Readme
String Emperor
Installation
This package can be installed using
npm i stringemperorUsage
Importing
const {
firstCharCapitalize,
reverse,
removeWhitespace,
countOccurrences,
isPalindrome,
slugify
} = require('stringemperor');
// or
const StringEmperor = require('stringemperor');Example Usage
console.log(StringEmperor.firstCharCapitalize('hello world')); // "Hello world"
console.log(StringEmperor.reverse('hello')); // "olleh"
console.log(StringEmperor.removeWhitespace(' hello world ')); // "helloworld"
console.log(StringEmperor.countOccurrences('hello world', 'l'));// 3
console.log(StringEmperor.isPalindrome('A man a plan a canal Panama')); // true
console.log(StringEmperor.slugify('Hello World! String Emperor')); // "hello-world-string-emperor"Functions
firstCharCapitalize(string)
Description: Capitalizes the first character of a string.
Parameters:
string(String) - The input string.Returns: String with the first letter capitalized.
reverse(string)
Description: Reverses the input string.
Parameters:
string(String) - The input string.Returns: Reversed string.
removeWhitespace(string)
Description: Removes all whitespaces from the input string.
Parameters:
string(String) - The input string.Returns: String without whitespaces.
countOccurrences(string, subString)
Description: Counts the occurrences of a substring within a string.
Parameters:
string(String) - The main string.subString(String) - The substring to count.
Returns: Number of occurences.
isPalindrome(string)
Description: Checks if a string is a palindrome (case-insensitive, ignoring spaces and special characters).
Parameters:
string(String) - The input string.Returns: Boolean -
trueif the string is a palindrome, otherwisefalse
slugify(string)
Description: Converts a string into a URL-friendly format.
Parameters:
string(String) - The input string.Returns: A slugified string.
Contributing
Contributions are welcome! Feel free to open issues or submit pull request on Github
Contact
I can be contacted on my email [email protected]. My website is ApoorvPathak.com
License
This project is licensed under ISC License. See LICENSE for more details.
