mcm-utils v1.0.8
MCM UTILS by MyCodedMind 🎉
A powerful and lightweight utility library for Angular applications.
🚀 Overview
MCM UTILS
is a collection of essential utility functions designed to simplify common tasks in Angular applications. Whether you need to manipulate arrays, format dates, or perform other operations, this library has you covered.
Features
- 🔧 Handy functions for everyday Angular development.
- 📦 Lightweight with no extra dependencies.
- 🛡️ Fully tested and optimized for Angular 18.
📦 Installation
To install the library, use npm:
npm install mcm-utils
🛠️ Usage
Import the utilities you need and use them in your Angular project:
import { capitalize, arrayToString } from 'mcm-utils';
console.log(capitalize(maria)); // Marias
console.log(arrayToString(['h',"e","l","l","o"])); // "hello"
📚 Available Utilities
String Utilities
Collection of functions for string manipulation and formatting.
replaceAccents(value: string): string
Replaces Spanish accents in a string with their non-accented equivalents.
import { replaceAccents } from 'mcm-utils-strings';
// Output: "Hello, World!"
const result = replaceAccents("Hélló, Wórld!");
removeAccents(value: string): string
Removes all diacritical marks from characters using Unicode normalization.
import { removeAccents } from './mcm-utils-strings';
// Output: "Hello, World!"
const result = removeAccents("Hélló, Wórld!");
removeLineJumps(value: string): string
import { removeLineJumps } from 'mcm-util-strings';
// Output: "Hello, World!"
const result = removeLineJumps("Hello,\nWorld!");
convertToSlug(value: string): string
Converts a string to a URL-friendly slug by removing accents, line breaks, and special characters.
import { convertToSlug } from 'mcm-util-strings';
// Output: "hello_world"
const result = convertToSlug("Hello, World!");
clearTextToSearch(query: string): string
Escapes special characters in a string to make it safe for use in search operations.
import { clearTextToSearch } from 'mcm-util-strings';
// Output: "search\[term\]"
const result = clearTextToSearch("search[term]");
toAwait(ms: number)
Delays execution for the specified number of milliseconds.
import { toAwait } from 'mcm-util';
await toAwait(1000)
HEADERS_FORM_MULTIPART
Provides HTTP headers for multipart form data.
import { HEADERS_FORM_MULTIPART } from 'mcm-util';
this.http.post('https://your-api.com/', formData, {headers:HEADERS_FORM_MULTIPART})
dataURIToBlob(dataURI)
Converts a data URI to a Blob object.
import { dataURIToBlob } from 'mcm-util';
dataURIToBlob("data:image/png;base64,...")
processImage(imgFile)
Processes an image file and returns a Photo
object with format, webPath, and base64 properties.
import { processImage } from 'mcm-util';
const photo:Photo = await processImage(file)
getBase64ImageFromURL(url)
Fetches a base64 encoded image from the specified URL.
import { getBase64ImageFromURL } from 'mcm-util';
const data = await getBase64ImageFromURL("https://example.com/image.png")
clone(object)
Deep clones an object.
import { clone } from 'mcm-util';
const copy = clone(originalObject);
arrayToString(strArray)
Converts an array of strings to a comma-separated string.
import { arrayToString } from 'mcm-util';
arrayToString(["a", "b", "c"], "-"); // "a - b - c"
capitalize(text)
Capitalizes the first letter of a string.
import { capitalize } from 'mcm-util';
capitalize("hello"); // "Hello"
toCapitalCase(sentence)
Converts a sentence to capital case, where the first letter of each word is capitalized.
import { toCapitalCase } from 'mcm-util';
toCapitalCase("hello world"); // "Hello World"
isSameDate(date, otherDate)
Checks if two dates are the same.
import { isSameDate } from 'mcm-util';
isSameDate(new Date(2025, 0, 1), new Date(2025, 0, 1)); // true
isInvalidURL(value)
Checks if a string is an invalid URL.
import { isInvalidURL } from 'mcm-util';
isInvalidURL("invalid-url"); // true
generateSecurePassword()
Generates a secure random password.
import { generateSecurePassword } from 'mcm-util-2';
generateSecurePassword() // abdc123_as@#0abdc123_as@#
createGoogleMapsLink(lat, lng)
Generates a link to Google Maps with a marker at the given latitude and longitude
import { createGoogleMapsLink } from 'mcm-util-2';
createGoogleMapsLink(-1.211, -1.211) //https://www.google.com/maps/search/?api=1&query=-1.211, -1.211
openWhatsapp()
Opens a new browser tab with a WhatsApp chat link for the given phone number
import { openWhatsapp } from 'mcm-util-2';
openWhatsapp('+593987654321') // open https://wa.me/+593987654321
buildQuery()
Build a query string from an object of key-value pairs.
import { buildQuery } from 'mcm-util-2';
buildQuery({ foo: 'bar', baz: 'qux' }) // => 'foo=bar&baz=qux'
📚 Available Pipes
Pipe | Description |
---|---|
capitalize | Capitalizes the first letter of a string. |
cutTxt | Truncates a string to a maximum length, default is 220. |
strNumber | Transforms the given value as a string to a number. |
🌟 Contributing
We welcome contributions! To get started:
- Fork this repository.
- Create a new branch for your feature or fix.
- Submit a pull request.
📄 License
This project is licensed under the MIT License. See the LICENSE file for details.
❤️ Acknowledgments
Special thanks to the Angular community for inspiring this project!
🤖 Team
💻 Yheison Roa
🎮 Bryan Castro