1.0.8 • Published 1 year ago

string-utils-basic v1.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

String Utilities Basic

A collection of basic string manipulation functions written in JavaScript. These functions provide a variety of utilities for validating, formatting, and transforming strings.

Functions Overview

Function NameDescription
basicValidationValidates if the input is a string.
removeAllWhiteSpacesExceptOnesInBetweenRemoves all unnecessary whitespace characters, except for single spaces between words.
removeNonAlphaNumericExceptSpacesInBetweenRemoves all non-alphanumeric characters except spaces.
capitalizeStringCapitalizes the first letter of each word in the string.
countWordsInStringCounts the number of words in a string.
reverseStringReverses the entire string.
reverseWordsInStringReverses the order of words in the string.
truncateStringTruncates the string to a specified length and appends "..." if truncated.
snakeStringConverts the string to snake_case.
kebabStringConverts the string to kebab-case.
camelStringConverts the string to camelCase.
isCamelCase, isSnakeCase, isKebabCaseBoolean functions to check if a string is in camelCase, snake_case, or kebab-case, respectively.
delJsCommentsDeletes JavaScript comments from a string.
getJsCommentsRetrieves JavaScript comments from a string.
hasJsCommentsChecks if a string has JavaScript comments.
countJsCommentsCounts the number of JavaScript comments in a string.
delCssCommentsDeletes CSS comments from a string.
getCssCommentsRetrieves CSS comments from a string.
hasCssCommentsChecks if a string has CSS comments.
countCssCommentsCounts the number of CSS comments in a string.
urlValidationValidates URLs according to a specified pattern.
getQueryParamsExtracts query parameters from a URL string.
getQueryStringExtracts the query string from a URL string.
hasIpAddressChecks if a string contains an IP address.
getIpAddressesRetrieves IP addresses from a string.
delIpAddressesDeletes IP addresses from a string.
countIpAddressesCounts the number of IP addresses in a string.
hasEmailChecks if a string contains email addresses.
getEmailsRetrieves email addresses from a string.
delEmailsDeletes email addresses from a string.
countEmailsCounts the number of email addresses in a string.
dateValidationValidates the format of a date string. Returns true if the date string matches common date formats, otherwise false.
hasEmojiChecks if a string contains emojis.
getEmojisRetrieves emojis from a string.
delEmojisDeletes emojis from a string.
countEmojisCounts the number of emojis in a string.

Note: Digits are included in snake_case, kebab-case, and camelCase.

Usage

To use these functions in your project, require the module and call the desired function:

const {
    basicValidation,
    removeAllWhiteSpacesExceptOnesInBetween,
    removeNonAlphaNumericExceptSpacesInBetween,
    capitalizeString,
    countWordsInString,
    reverseString,
    reverseWordsInString,
    truncateString,
    snakeString,
    kebabString,
    camelString,
    isCamelCase,
    isSnakeCase,
    isKebabCase,
    delJsComments,
    getJsComments,
    hasJsComments,
    countJsComments,
    delCssComments,
    getCssComments,
    hasCssComments,
    countCssComments,
    urlValidation,
    getQueryParams,
    getQueryString,
    hasIpAddress,
    getIpAddresses,
    delIpAddresses,
    countIpAddresses,
    hasEmail,
    getEmails,
    delEmails,
    countEmails,
    dateValidation,
    hasEmoji,
    getEmojis,
    delEmojis,
    countEmojis
} = require('string-utils-basic');

// Example usage:

console.log(capitalizeString("hello world"));

// Outputs: "Hello World"

Installation

git clone https://github.com/your-username/string-utils-basic.git
cd string-utils-basic
npm i

Running Tests

npm test

Project By

Apoorv Shrivastava

npm package link

https://www.npmjs.com/package/string-utils-basic

Contributing

Feel free to submit issues or pull requests if you have suggestions or improvements.

License

This project is licensed under the MIT License.

This summary provides a clear overview of the functionality provided by your string utility functions, along with instructions on how to use, install, and test them.