npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nikita-naredi/string-utility

v1.0.3

Published

This is a string utility package

Downloads

111

Readme

@nikita-naredi/string-utility

A utility package to parse strings

Installation

Using npm:

npm install --save @nikita-naredi/string-utility

Using yarn:

yarn add @nikita-naredi/string-utility

Usage

To use the string-utility package in your project, first import it:

const stringUtility = require('@nikita-naredi/string-utility');

Or if you're using ES6 modules:

import stringUtility from '@nikita-naredi/string-utility';

API Reference

| Function | Description | Example | Output | | ------------------------- | --------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | --------------------- | | toUpperSnakeCase | Converts the input string to upper snake case. | stringUtility.toUpperSnakeCase('Hello World'); | 'HELLO_WORLD' | | toReverseCase | Reverses the case of each character in the input string. | stringUtility.toReverseCase('Hello World'); | 'hELLO wORLD' | | toAlternatingCase | Converts the input string to alternating case. | stringUtility.toAlternatingCase('hello world'); | 'HeLlO wOrLd' | | toCamelCase | Converts the input string to camel case. | stringUtility.toCamelCase('hello world'); | 'helloWorld' | | toPascalCase | Converts the input string to pascal case. | stringUtility.toPascalCase('hello world'); | 'HelloWorld' | | toKebabCase | Converts the input string to kebab case. | stringUtility.toKebabCase('hello world'); | 'hello-world' | | toSnakeCase | Converts the input string to snake case. | stringUtility.toSnakeCase('hello world'); | 'hello_world' | | toCapitalizedCase | Capitalizes the first letter of each word in the input string. | stringUtility.toCapitalizedCase('hello world'); | 'Hello World' | | toSentenceCase | Converts the input string to sentence case. | stringUtility.toSentenceCase('hello world'); | 'Hello world' | | toTitleCase | Converts the input string to title case. | stringUtility.toTitleCase('hello world'); | 'Hello World' | | removeNonAlpha | Removes all non-alphabetic characters from the input string. | stringUtility.removeNonAlpha('Hello, World! 123'); | 'HelloWorld' | | containsOnlyAlpha | Checks if the input string contains only alphabetic characters. | stringUtility.containsOnlyAlpha('Hello'); | true | | removeDuplicates | Removes duplicate characters from the input string. | stringUtility.removeDuplicates('Hello'); | 'Helo' | | findSubstringOccurrences | Counts the number of occurrences of a substring within the input string. | stringUtility.findSubstringOccurrences('Hello, World! 123', 'el'); | 1 | | replaceSpecificOccurrence | Replaces the nth occurrence of a substring with a new substring in the input string. | stringUtility.replaceSpecificOccurrence('Hello, World! 123', 'l', 'i', '1'); | 'Helio, World! 123' | | replaceAllOccurrences | Replaces all occurrences of a substring with a new substring in the input string. | stringUtility.replaceAllOccurrences('Hello, World! 123', 'l', 'i'); | 'Heiio, Worid! 123' | | caseString | Converts the input string to the specified case type (e.g., 'upper', 'lower', 'title'). | stringUtility.caseString('Hello, World!', 'alternate'); | 'hELLo, wORLD' | | countWords | Counts the number of words in the input string. | stringUtility.countWords('Hello world'); | 2 | | countCharacters | Counts the total number of characters in the input string. | stringUtility.countCharacters('Hello, World!'); | 13 | | countUniqueCharacters | Counts the number of unique characters in the input string. | stringUtility.countUniqueCharacters('Hello'); | 4 | | countVowels | Counts the number of vowels in the input string. | stringUtility.countVowels('Hello world'); | 3 | | countConsonants | Counts the number of consonants in the input string. | stringUtility.countConsonants('Hello world'); | 7 | | countSpecialCharacters | Counts the number of special characters in the input string. | stringUtility.countSpecialCharacters('Hello, World!'); | 2 | | countDigits | Counts the number of digits in the input string. | stringUtility.countDigits('Hello123World'); | 3 | | countOccurrences | Counts the number of occurrences of a specific substring in the input string. | stringUtility.countOccurrences('Hello world', 'o'); | 2 | | countSentences | Counts the number of sentences in the input string. | stringUtility.countSentences('Hello world. How are you? I am fine.'); | 3 | | countParagraphs | Counts the number of paragraphs in the input string. | stringUtility.countParagraphs('Paragraph 1.\n\nParagraph 2.\n\nParagraph 3.'); | 3 | | countLines | Counts the number of lines in the input string. | stringUtility.countLines('Line 1\nLine 2\nLine 3'); | 3 | | countUniqueWords | Counts the number of unique words in the input string. | stringUtility.countUniqueWords('The quick brown fox jumps over the lazy dog'); | 8 | | countSubstrings | Counts the number of occurrences of a substring in the input string. | stringUtility.countSubstrings('hello hello world', 'hello'); | 2 | | generateRandomString | Generates a random string of specified length and character set. | stringUtility.generateRandomString(10, 'alphanumeric'); | 'a2b3c4d5e6' | | removeNonAlpha | Removes all non-alphabetic characters from the input string. | stringUtility.removeNonAlpha('Hello, World! 123'); | 'HelloWorld' | | removeSubstring | Removes all occurrences of a specified substring from the input string. | stringUtility.removeSubstring('Hello World', 'o'); | 'Hell Wrld' | | removeDuplicates | Removes duplicate characters from the input string, keeping only the first occurrence. | stringUtility.removeDuplicates('hello'); | 'helo' | | replaceFirstOccurrence | Replaces the first occurrence of a substring with a new string. | stringUtility.replaceFirstOccurrence('Hello World', 'o', '0'); | 'Hell0 World' | | replaceLastOccurrence | Replaces the last occurrence of a substring with a new string. | stringUtility.replaceLastOccurrence('Hello World', 'o', '0'); | 'Hello W0rld' | | isAlpha | Checks if the input string contains only alphabetic characters. | stringUtility.isAlpha('HelloWorld'); | true | | | | stringUtility.isAlpha('Hello123'); | false | | isPalindrome | Checks if the input string is a palindrome (reads the same forwards and backwards). | stringUtility.isPalindrome('racecar'); | true | | | | stringUtility.isPalindrome('hello'); | false | | isAnagram | Checks if two input strings are anagrams of each other. | stringUtility.isAnagram('listen', 'silent'); | true | | | | stringUtility.isAnagram('hello', 'world'); | false | | isPangram | Checks if the input string is a pangram (contains all letters of the alphabet). | stringUtility.isPangram('The quick brown fox jumps over the lazy dog'); | true | | | | stringUtility.isPangram('Hello world'); | false |

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.