# @hua-labs/utils - AI Documentation
# Version: 2.0.0
# Auto-generated by generate-docs — do not edit manually

package:
  name: "@hua-labs/utils"
  version: "2.0.0"
  description: "Common utility functions for the hua ecosystem"
  license: "MIT"

overview: "A comprehensive utility library for the hua ecosystem. Includes class name merging (Tailwind-safe), formatters, performance utilities, validation, string manipulation, and sanitization functions."

exports:
  main:
    path: "@hua-labs/utils"
    provides:
      - name: "cn"
        type: "function"
        description: "Tailwind-safe class name merging (clsx + tailwind-merge)"
      - name: "formatDate"
        type: "function"
        description: "Format a Date or date string using Intl.DateTimeFormat with ko-KR locale. Accepts optional Intl.DateTimeFormatOptions."
      - name: "formatNumber"
        type: "function"
        description: "Format a number using Intl.NumberFormat with ko-KR locale. Accepts optional Intl.NumberFormatOptions."
      - name: "formatFileSize"
        type: "function"
        description: "Convert a byte count into a human-readable string (e.g. '1.5 MB')."
      - name: "classifyRelativeDate"
        type: "function"
        description: ""
      - name: "formatRelativeDate"
        type: "function"
        description: ""
      - name: "formatTimeAgo"
        type: "function"
        description: "Return a Korean relative time string for a past date (e.g. '3분 전', '2일 전')."
      - name: "debounce"
        type: "function"
        description: "Debounce function calls with configurable delay"
      - name: "throttle"
        type: "function"
        description: "Throttle function calls to execute at most once per interval."
      - name: "memoize"
        type: "function"
        description: "Cache function results by argument key. Accepts optional resolver to compute the cache key."
      - name: "delay"
        type: "function"
        description: "Return a Promise that resolves after the given number of milliseconds."
      - name: "retry"
        type: "function"
        description: "Retry an async function up to maxAttempts times with exponential back-off between attempts."
      - name: "retryWithAbort"
        type: "function"
        description: ""
      - name: "validateEmail"
        type: "function"
        description: "Email format validation"
      - name: "validateUrl"
        type: "function"
        description: "Return true if the string is a valid absolute URL (uses URL constructor)."
      - name: "validatePhoneNumber"
        type: "function"
        description: "Validate a Korean mobile phone number (01x-xxxx-xxxx format)."
      - name: "validateNumberRange"
        type: "function"
        description: "Return true if a number is within the inclusive [min, max] range."
      - name: "validateStringLength"
        type: "function"
        description: "Return true if a string length is within the inclusive [min, max] range."
      - name: "generateId"
        type: "function"
        description: "Generate a unique ID string with optional prefix (default: 'id'). Uses Date.now + random suffix."
      - name: "generateUUID"
        type: "function"
        description: "Generate a random UUID v4 string."
      - name: "slugify"
        type: "function"
        description: "Convert a string into a URL-friendly slug (lowercase, hyphens, no special chars)."
      - name: "truncate"
        type: "function"
        description: "Truncate a string to the given length and append a suffix (default: '...'). Handles multi-byte characters."
      - name: "toCamelCase"
        type: "function"
        description: "Convert a string to camelCase."
      - name: "toPascalCase"
        type: "function"
        description: "Convert a string to PascalCase."
      - name: "toSnakeCase"
        type: "function"
        description: "Convert a string to snake_case."
      - name: "toKebabCase"
        type: "function"
        description: "Convert a string to kebab-case."
      - name: "capitalize"
        type: "function"
        description: "Capitalize the first character and lowercase the rest of a string."
      - name: "titleCase"
        type: "function"
        description: "Capitalize the first character of every word in a string."
      - name: "sanitizeInput"
        type: "function"
        description: "XSS prevention input sanitizer"
      - name: "sanitizeTitle"
        type: "function"
        description: "Sanitize a title string — removes HTML tags and dangerous patterns, enforces optional maxLength (default: 100)."
      - name: "sanitizeEmail"
        type: "function"
        description: "Sanitize an email address — trims whitespace and lowercases."
      - name: "sanitizeName"
        type: "function"
        description: "Sanitize a name string — removes HTML tags and XSS patterns."
      - name: "escapeHtml"
        type: "function"
        description: 'Escape HTML special characters (&, <, >, ", ''). Intended for email body rendering, not general React output.'
      - name: "maskEmailForLog"
        type: "function"
        description: "Mask an email address for safe logging (GDPR/CCPA). Shows only the first N local-part characters (default: 3), e.g. 'use***@***'."
      - name: "deepMerge"
        type: "function"
        description: "Recursive object merge — handles arrays, dates, nested objects, null/undefined."
      - name: "pick"
        type: "function"
        description: "Select keys from object. Type-safe with keyof."
      - name: "omit"
        type: "function"
        description: "Exclude keys from object. Type-safe with keyof."
      - name: "groupBy"
        type: "function"
        description: "Group array items by key or function. Returns Record<string, T[]>."
      - name: "keyBy"
        type: "function"
        description: "Index array items by key or function. Returns Record<string, T> (last wins)."
      - name: "chunk"
        type: "function"
        description: "Split array into chunks of given size."
      - name: "unique"
        type: "function"
        description: "Deduplicate array by strict equality."
      - name: "uniqueBy"
        type: "function"
        description: "Deduplicate array by custom key function."
      - name: "flatten"
        type: "function"
        description: "Flatten nested arrays to given depth (default 1)."
      - name: "clamp"
        type: "function"
        description: "Clamp number between min and max."
      - name: "lerp"
        type: "function"
        description: "Linear interpolation between start and end by t."
      - name: "mapRange"
        type: "function"
        description: "Map value from one range to another."
      - name: "isObject"
        type: "function"
        description: "Check if value is a plain object (not null, not array, not Date)."
      - name: "isArray"
        type: "function"
        description: "Array.isArray wrapper with type narrowing."
      - name: "isString"
        type: "function"
        description: "typeof string check with type narrowing."
      - name: "isEmpty"
        type: "function"
        description: "Check for empty string, empty array, empty object, null, or undefined."
      - name: "isNil"
        type: "function"
        description: "Check for null or undefined."
      - name: "buildQueryString"
        type: "function"
        description: "Convert Record to query string. Handles arrays, skips null/undefined."
      - name: "parseQueryString"
        type: "function"
        description: "Parse query string to Record. Handles repeated keys as arrays."
      - name: "mergeRefs"
        type: "function"
        description: ""
      - name: "RelativeDateClass"
        type: "type"
        description: ""
      - name: "RetryWithAbortOptions"
        type: "type"
        description: ""

features:
  - "cn() class merging — Tailwind-safe class name merging via clsx + tailwind-merge"
  - "Formatters — Date, number, file size, relative time"
  - "Performance — debounce, throttle, memoize, delay, retry"
  - "Validation — Email, password, URL, phone number, range checks"
  - "String utils — UUID, slugify, truncate, case conversion (camel/pascal/snake/kebab)"
  - "Sanitization — XSS prevention, HTML escaping, email masking"
  - "Object utils — deepMerge, pick, omit (type-safe)"
  - "Collection utils — groupBy, keyBy, chunk, unique, uniqueBy, flatten"
  - "Math utils — clamp, lerp, mapRange"
  - "Type guards — isObject, isArray, isString, isEmpty, isNil"
  - "URL utils — buildQueryString, parseQueryString"
  - "Ref utils — mergeRefs (combine multiple refs)"
  - "retryWithAbort — async retry with AbortController"

related_packages:
  - "@hua-labs/hua"
  - "@hua-labs/hooks"

compatibility:
  react: ">=19.0.0"
  node: ">=20.0.0"
