Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gramsay7/string-lib

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gramsay7/string-lib

StringFormatter is a utility library that provides a collection of static methods for string manipulation in JavaScript. It includes functions for capitalizing the first letter of a string, converting a string to all caps, capitalizing all words in a stri

  • 1.0.3
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

StringFormatter

StringFormatter is a utility library that provides a collection of static methods for string manipulation in JavaScript. It includes functions for capitalizing the first letter of a string, converting a string to all caps, capitalizing all words in a string, and much more.

Installation

npm package: https://www.npmjs.com/package/@gramsay7/string-lib

Use the package manager npm to install StringFormatter.

npm install @gramsay7/string-lib

Usage

import StringFormatter from 'string-formatter';

let str = "hello world";

console.log(StringFormatter.capitalizeFirstLetter(str)); // "Hello world"
console.log(StringFormatter.allCaps(str)); // "HELLO WORLD"
console.log(StringFormatter.capitalizeWords(str)); // "Hello World"

API

capitalizeFirstLetter(string: string): string

Capitalizes the first letter of the string.

allCaps(string: string): string

Converts the entire string to uppercase.

capitalizeWords(string: string): string

Capitalizes the first letter of each word in the string.

capitalizedHeadline(string: string): string

Capitalizes the first letter of each word in the string, except for certain small words such as 'the', 'in', 'a', 'an', 'and', 'but', 'for', 'at', 'by', 'from'.

removeExtraSpaces(string: string): string

Removes extra spaces from the string.

kebobCase(string: string, charToReplace = '-'): string

Converts the string to kebob-case (also known as dash-case or lisp-case).

snakeCase(string: string): string

Converts the string to snake_case.

camelCase(string: string): string

Converts the string to camelCase.

shift(string: string, number = 1): string

Shifts the characters in the string to the right by the specified number of positions.

makeHashTag(string: string): string[]

Creates an array of hashtags from the words in the string. The array is sorted by word length, with the longest words first, and includes up to three words.

isEmpty(string: string): boolean

Checks if the string is empty, ignoring whitespace characters.

License

MIT

FAQs

Package last updated on 02 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc