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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@maz-ui/utils

v4.3.0

Published

Utils of maz-ui for JavaScript/TypeScript users

Readme

@maz-ui/utils

JavaScript/TypeScript utility functions for the Maz-UI ecosystem - String manipulation, date formatting, debouncing, throttling, and more.

Installation

npm install @maz-ui/utils

Features

  • String utilities - Case conversion, normalization, and manipulation
  • Date and number formatting - Localized formatting with internationalization support
  • Performance utilities - Debouncing, throttling, and optimization helpers
  • Browser utilities - Client/server detection, user visibility, and environment checks
  • TypeScript helpers - Advanced type utilities for better type safety
  • Phone number formatting - International phone number utilities
  • Currency formatting - Multi-currency formatting support
  • Validation utilities - Deep equality checks and data validation
  • DOM utilities - Script loading, textarea autogrow, and swipe handling

Usage

Basic Import

import { camelCase, debounce, formatDate } from '@maz-ui/utils'

// String utilities
const camelCased = camelCase('hello-world') // 'helloWorld'

// Date formatting
const formatted = formatDate(new Date(), 'en-US') // '12/25/2023'

// Performance utilities
const debouncedFn = debounce(() => console.log('Called!'), 300)

Modular Imports

// Import TypeScript helpers
import type { DeepPartial } from '@maz-ui/utils/ts-helpers/DeepPartial'
// Import specific helpers
import { camelCase } from '@maz-ui/utils/helpers/camelCase'
import { debounce } from '@maz-ui/utils/helpers/debounce'
import { formatDate } from '@maz-ui/utils/helpers/formatDate'

Available Utilities

String Utilities

  • camelCase - Convert strings to camelCase
  • capitalize - Capitalize first letter of strings
  • kebabCase - Convert strings to kebab-case
  • pascalCase - Convert strings to PascalCase
  • snakeCase - Convert strings to snake_case
  • normalizeString - Normalize strings for comparison

Date and Number Formatting

  • formatDate - Format dates with locale support
  • formatNumber - Format numbers with locale support
  • formatCurrency - Format currency values with locale support

Performance Utilities

  • debounce - Debounce function calls
  • debounceCallback - Debounce with callback support
  • debounceId - Debounce with unique identifiers
  • throttle - Throttle function calls
  • throttleId - Throttle with unique identifiers

Browser and Environment

  • isClient - Check if running in client environment
  • isServer - Check if running in server environment
  • isStandaloneMode - Check if app is in standalone mode
  • userVisibility - Track user visibility state
  • getBrowserLocale - Get browser locale settings

Validation and Comparison

  • isEqual - Deep equality comparison
  • checkAvailability - Check resource availability
  • truthyFilter - Filter truthy values from arrays

DOM and UI Utilities

  • scriptLoader - Dynamic script loading
  • TextareaAutogrow - Automatic textarea height adjustment
  • swipeHandler - Touch swipe gesture handling
  • idleTimeout - Idle state management

Phone and Location

  • formatPhoneNumber - Format international phone numbers
  • countryCodeToUnicodeFlag - Convert country codes to flag emojis
  • getCountryFlagUrl - Get country flag image URLs
  • fetchLocaleIp - Fetch user locale from IP

Utility Functions

  • sleep - Promise-based delay utility
  • getErrorMessage - Extract error messages safely

TypeScript Helpers

Advanced type utilities for enhanced TypeScript development:

  • DeepPartial - Make all properties optional recursively
  • DeepKeyOf - Get all nested keys of an object type
  • FlattenObjectKeys - Flatten object keys to dot notation
  • GenericInstanceType - Extract instance type from constructor
  • InferMaybeRef - Infer type from Vue ref or regular value
import type { DeepKeyOf, DeepPartial } from '@maz-ui/utils'

interface User {
  profile: {
    name: string
    email: string
  }
}

type PartialUser = DeepPartial<User> // All properties optional
type UserKeys = DeepKeyOf<User> // 'profile' | 'profile.name' | 'profile.email'

Performance Examples

import { debounce, throttle } from '@maz-ui/utils'

// Debounce search input
const debouncedSearch = debounce((query: string) => {
  performSearch(query)
}, 300)

// Throttle scroll events
const throttledScroll = throttle(() => {
  updateScrollPosition()
}, 16)

Formatting Examples

import { formatCurrency, formatDate, formatPhoneNumber } from '@maz-ui/utils'

// Currency formatting
const price = formatCurrency(1234.56, 'USD', 'en-US') // '$1,234.56'

// Date formatting
const date = formatDate(new Date(), 'fr-FR') // '25/12/2023'

// Phone formatting
const phone = formatPhoneNumber('+33123456789', 'international')

Requirements

  • Node.js >= 18.0.0
  • TypeScript support included
  • Tree-shakeable for optimal bundle size

Contributing

Contributions are welcome! Please ensure:

  • New utilities follow existing patterns
  • TypeScript types are properly defined
  • Unit tests are included
  • Documentation is updated accordingly

License

MIT License - see LICENSE file for details.