1.0.0 • Published 9 months ago

@xiaozhu2007/uppercase v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@xiaozhu2007/uppercase

NPM Version License

A Node.js module to convert strings to uppercase and provide related utilities.

Installation

npm install @xiaozhu2007/uppercase

Usage

Convert a String to Uppercase

const { toUpperCase } = require('@xiaozhu2007/uppercase');

console.log(toUpperCase("hello world"));  // Output: HELLO WORLD

Convert the First Letter of Each Word to Uppercase

const { toTitleCase } = require('@xiaozhu2007/uppercase');

console.log(toTitleCase("hello world"));  // Output: Hello World

Check if a String is All Uppercase

const { isUpperCase } = require('@xiaozhu2007/uppercase');

console.log(isUpperCase("HELLO WORLD"));  // Output: true
console.log(isUpperCase("Hello World"));  // Output: false

Convert Characters at Specific Positions to Uppercase

const { uppercaseAtPositions } = require('@xiaozhu2007/uppercase');

console.log(uppercaseAtPositions("hello world", [0, 6]));  // Output: Hello World

API

toUpperCase(str)

  • Parameters:
    • str (string): The string to convert to uppercase.
  • Returns:
    • (string): The converted uppercase string.

toTitleCase(str)

  • Parameters:
    • str (string): The string to convert.
  • Returns:
    • (string): The title-cased string.

isUpperCase(str)

  • Parameters:
    • str (string): The string to check.
  • Returns:
    • (boolean): Returns true if the string is all uppercase, otherwise false.

uppercaseAtPositions(str, positions)

  • Parameters:
    • str (string): The string to convert.
    • positions (number[]): An array of character positions (0-indexed).
  • Returns:
    • (string): The converted string.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

1.0.0

9 months ago