npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

azmoodan

v1.0.2

Published

Azmoodan is a JavaScript and TypeScript utility package that provides various helper functions for number manipulation, validations, and renderings.

Downloads

97

Readme

Azmoodan

Azmoodan is a JavaScript and TypeScript utility package that provides various helper functions for number manipulation, validations, and renderings.

Table of Contents

  1. Installation
  2. Usage
  3. API Reference
  4. Contributing
  5. License
  6. Contributors

Installation

You can install Azmoodan using npm:

npm install azmoodan

Or using yarn:

yarn add azmoodan

Usage

You can import the functions you need from Azmoodan:

import { randomNumber, randomRGB, randomPassword ,faNumToEn, enNumToFa, numberToWordsFa, numberToWordsEn, maskPhoneNumber, formatPhoneNumber, validateEmail, checkStrongPassword, personalRegex, rangeCharacter, rangeNumber, isEmpty, getFileSize, checkFileType, isImage, isVideo, isAudio, replaceNumbers, replaceAntiNumbers, replaceAntiCharacters, replaceSpaces, isValidPhoneNumber, isValidMobileNumber, isValidateURL, isValidZipCode, isValidDate, isValidTime, extractDates, extractTimes, convertDate, getDateDifference } from 'azmoodan';

API Reference

Number Utilities

(Number utilities section remains the same as in the previous version)

Validations

validateEmail(email: string): boolean

Validates an email address.

const isValid = validateEmail('[email protected]');
console.log(isValid); // Output: true

checkStrongPassword(password: string): IStrongPassword

Checks the strength of a password and returns an object with details.

const passwordStrength = checkStrongPassword('MyStr0ng@Password');
console.log(passwordStrength);
/* Output:
{
  percent: 100,
  details: {
    haveSign: true,
    haveCharacter: true,
    haveNumber: true,
    moreThanEight: true
  }
}
*/

personalRegex(ReGex: RegExp, value: any): boolean

Tests a value against a custom regular expression.

const isMatch = personalRegex(/^\d{3}-\d{3}-\d{4}$/, '123-456-7890');
console.log(isMatch); // Output: true

rangeCharacter(min: number = 0, max: number = Infinity, value: string | number): number

Checks if the length of a string is within a specified range and returns the difference.

const diff = rangeCharacter(5, 10, 'Hello');
console.log(diff); // Output: 5 (10 - 5)

rangeNumber(min: number = 0, max: number = Infinity, value: number): boolean

Checks if a number is within a specified range.

const isInRange = rangeNumber(1, 100, 50);
console.log(isInRange); // Output: true

isEmpty(value: any): boolean

Checks if a value is empty (including empty objects and arrays).

console.log(isEmpty([])); // Output: true
console.log(isEmpty({ key: 'value' })); // Output: false

getFileSize(file: File): number

Returns the size of a file in bytes.

const fileSize = getFileSize(myFile);
console.log(fileSize); // Output: file size in bytes

checkFileType(file: File): string

Returns the file extension.

const fileType = checkFileType(myFile);
console.log(fileType); // Output: 'jpg' (for example)

isImage(file: File | string): boolean

Checks if a file is an image based on its extension.

const isImageFile = isImage('photo.jpg');
console.log(isImageFile); // Output: true

isVideo(file: File | string): boolean

Checks if a file is a video based on its extension.

const isVideoFile = isVideo('movie.mp4');
console.log(isVideoFile); // Output: true

isAudio(file: File | string): boolean

Checks if a file is an audio file based on its extension.

const isAudioFile = isAudio('song.mp3');
console.log(isAudioFile); // Output: true

replaceNumbers(value: string | number, char: string = ''): string

Replaces all numbers in a string with a specified character.

const replaced = replaceNumbers('abc123', '*');
console.log(replaced); // Output: 'abc***'

replaceAntiNumbers(value: string | number, char: string = ''): string

Replaces all non-numeric characters in a string with a specified character.

const replaced = replaceAntiNumbers('abc123', '*');
console.log(replaced); // Output: '***123'

replaceAntiCharacters(value: string | number, char: string = ''): string

Replaces all non-word characters in a string with a specified character.

const replaced = replaceAntiCharacters('abc_123!@#', '*');
console.log(replaced); // Output: 'abc*123***'

replaceSpaces(value: string | number, char: string = ''): string

Replaces all spaces in a string with a specified character.

const replaced = replaceSpaces('Hello World', '_');
console.log(replaced); // Output: 'Hello_World'

isValidPhoneNumber(phone: number | string, prefix: boolean = false): boolean

Validates a phone number.

const isValid = isValidPhoneNumber('123-12345678', true);
console.log(isValid); // Output: true

isValidMobileNumber(phone: number | string): boolean

Validates a mobile number (specifically for Iranian mobile numbers).

const isValid = isValidMobileNumber('09123456789');
console.log(isValid); // Output: true

isValidateURL(url: string): boolean

Validates a URL.

const isValid = isValidateURL('https://www.example.com');
console.log(isValid); // Output: true

isValidZipCode(zipcode: string | number): boolean

Validates a zip code.

const isValid = isValidZipCode('12345-67890');
console.log(isValid); // Output: true

isValidDate(date: Date | string): boolean

Validates a date string in various formats.

const isValid = isValidDate('2023-05-15');
console.log(isValid); // Output: true

isValidTime(time: string): boolean

Validates a time string.

const isValid = isValidTime('14:30:00');
console.log(isValid); // Output: true

extractDates(text: string): string[]

Extracts all dates from a text string.

const dates = extractDates('Meeting on 2023-05-15 and 2023-06-01');
console.log(dates); // Output: ['2023-05-15', '2023-06-01']

extractTimes(text: string): string[]

Extracts all times from a text string.

const times = extractTimes('Meeting at 09:00 AM and lunch at 12:30 PM');
console.log(times); // Output: ['09:00 AM', '12:30 PM']

convertDate(date: Date | string, format: string = "Fa-IR"): Date | string

Converts a date to a localized string representation.

const localDate = convertDate(new Date(), 'en-US');
console.log(localDate); // Output: localized date string

getDateDifference(dateOne: Date | string, dateTwo: Date | string): number | null

Calculates the difference in days between two dates.

const diff = getDateDifference('2023-05-15', '2023-06-01');
console.log(diff); // Output: 17

Renderings

(This section is a placeholder. Please add descriptions and examples for the rendering functions from your renders.ts file.)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Contributors

Support

If you have any questions or issues, please open an issue on the GitHub repository.