@asuarez18/my-first-package
v1.0.1
Published
A versatile collection of JavaScript utilities for string formatting, HTML entity conversion, and mathematical operations
Maintainers
Readme
@asuarez18/my-first-package
A lightweight collection of essential JavaScript utility functions for string manipulation, security, and mathematical operations.
🚀 Installation
Install the package via npm:
npm install @asuarez18/my-first-package🛠 Usage
Since this package uses ECMAScript Modules (ESM), you can import the functions directly into your project.
import { convertHTML, sumAll, generatePassword, titleCase } from '@asuarez18/my-first-package';📚 API Reference
convertHTML(str)
Converts characters &, <, >, ", and ' in a string to their corresponding HTML entities. Use this to prevent XSS attacks or display raw code in HTML.
- Arguments:
str(string) - Returns: (string) The escaped string.
convertHTML("Dolce & Gabbana"); // "Dolce & Gabbana"sumAll([num1, num2])
Takes an array of two numbers and returns the sum of those two numbers plus the sum of all numbers between them. The lowest number will not always come first.
- Arguments:
arr(Array) - Returns: (Number) Total sum.
sumAll([1, 4]); // 10 (1+2+3+4)
sumAll([10, 5]); // 45generatePassword(lenPass)
Generates a random secure password including uppercase, lowercase, numbers, and special characters.
- Arguments:
lenPass(Number) - The desired length. - Returns: (string) The generated password.
generatePassword(12); // "aB3!jK9@pQ1$"titleCase(title)
Converts a string to Title Case, where the first letter of every word is capitalized and the rest are lowercase.
- Arguments:
title(string) - Returns: (string) The formatted string.
titleCase("I'm a LITTLE tea pot"); // "I'm A Little Tea Pot"📝 License
This project is licensed under the ISC License.
