@noobdevelova/stringformatter
Version:
Format String For Data Consistency
61 lines (41 loc) • 2.06 kB
Markdown
`String Formatter` is a lightweight JavaScript library designed to provide easy-to-use functions for capitalizing strings. Whether you need to capitalize the first letter of a string, each part of a full name, or just a single name, this library simplifies these tasks with straightforward methods.
- **Capitalize First**: Capitalizes the first letter of a given string and converts the rest of the string to lowercase.
- **Capitalize Full Name**: Capitalizes the first letter of each part of a full name, making it suitable for formatting names in user interfaces.
- **Capitalize Single Name**: Capitalizes the first letter of a single name, useful for title cases and user-friendly displays.
You can install the library via npm:
```bash
npm install @noobdevelova/stringformatter
```
Example usage of this library:
```js
import {
capitalizeFirst,
capitalizeFullName,
capitalizeSingleName,
capitalizeAll,
} from "@noobdevelova/stringformatter";
// Example usage
// Capitalize the first letter of a single name
const singleName = capitalizeSingleName("john");
console.log(singleName); // Output: John
// Capitalize the first letter of each part of a full name
const fullName = capitalizeFullName("john doe");
console.log(fullName); // Output: John Doe
// Capitalize the first letter of a string
const firstNameCapitalized = capitalizeFirst("example");
console.log(firstNameCapitalized); // Output: Example
// Capitalize the first letter of a string and lower the rest
const firstNameCapitalizedAndFix = capitalizeFirstAndFix("eXAMPle");
console.log(firstNameCapitalizedAndFix); // Output: Example
// Capitalize all letter of a string
const allCapitalized = capitalizeAll("example");
console.log(firstNameCapitalized); // Output: EXAMPLE
```
- **Author**: Randi Risdiansyah
This library is licensed under the [MIT License](https://github.com/git/git-scm.com/blob/main/MIT-LICENSE.txt).