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 🙏

© 2026 – Pkg Stats / Ryan Hefner

ui-formatter

v0.1.3

Published

Format web UI

Readme

ui-formatter

A lightweight, zero-dependency TypeScript utility library for formatting dates, times, numbers, and phone numbers.

Designed for applications that require high performance, small bundle size, and no external dependencies.


Features

  • 🚀 Zero dependencies
  • ⚡ High-performance implementations
  • 📅 Date formatting
  • 🕒 Time formatting
  • 🔢 Number formatting
  • ☎️ Phone/Fax formatting
  • 🧹 Phone normalization
  • 💯 TypeScript support
  • 🌍 Works in Browser and Node.js

Installation

npm install ui-formatter

or

yarn add ui-formatter

Quick Example

import {
    formatDate,
    formatDateTime,
    formatNumber,
    formatInteger,
    formatPhone
} from "ui-formatter"

const date = new Date()

formatDate(date, "MM/dd/yyyy")
// 07/02/2026

formatDateTime(date, "yyyy-MM-dd")
// 2026-07-02 14:35

formatNumber(1234567.89, 2)
// 1,234,567.89

formatInteger(1000000)
// 1,000,000

formatPhone("8005551234")
// 800 555-1234

API


Date Utilities

getDateFormat()

Returns the default date format.

const format = getDateFormat()

// M/d/yyyy

addDays()

Returns a new date with the specified number of days added.

const tomorrow = addDays(new Date(), 1)

formatDate()

Formats a Date using a custom format.

Supported tokens:

| Token | Description | |--------|-------------| | yyyy | 4-digit year | | yy | 2-digit year | | MM | 2-digit month | | M | Month | | dd | 2-digit day | | d | Day |

Example

formatDate(new Date(), "yyyy-MM-dd")

// 2026-07-02

formatTime()

Returns

HH:mm

Example

formatTime(new Date())

// 15:30

formatLongTime()

Returns

HH:mm:ss

Example

formatLongTime(new Date())

// 15:30:45

formatFullTime()

Returns

HH:mm:ss.SSS

Example

formatFullTime(new Date())

// 15:30:45.123

formatDateTime()

Formats

<Date> <HH:mm>

Example

formatDateTime(new Date(), "yyyy-MM-dd")

// 2026-07-02 15:30

formatLongDateTime()

Formats

<Date> <HH:mm:ss>

formatFullDateTime()

Formats

<Date> <HH:mm:ss.SSS>

datetimeToString()

Converts a Date into ISO-like format.

datetimeToString(new Date())

// 2026-07-02T15:30:45

dateToString()

Returns a compact timestamp.

dateToString(new Date())

// 20260702153045

Milliseconds may be included.

dateToString(new Date(), true)

// 20260702153045123

Number Utilities


formatInteger()

Formats an integer with thousands separators.

formatInteger(123456789)

// 123,456,789

Custom separator

formatInteger(123456789, ".")

// 123.456.789

formatNumber()

Formats decimal numbers.

formatNumber(1234567.89, 2)

// 1,234,567.89

Custom separators

formatNumber(
    1234567.89,
    2,
    ",",
    "."
)

// 1.234.567,89

Phone Utilities


normalizePhone()

Removes all characters except digits and +.

normalizePhone("(800) 555-1234")

// 8005551234

normalizeFax()

Alias of

normalizePhone()

formatPhone()

Formats phone numbers into a readable representation.

formatPhone("8005551234")

// 800 555-1234

Supports

  • US numbers
  • international numbers
  • partial numbers

formatFax()

Formats fax numbers.

formatFax("0212345678")

// 02-12345678

Utility Functions


isNotEmpty()

Checks whether an array or string is not empty.

isNotEmpty([])

// false

isNotEmpty("hello")

// true

isChecked()

Utility for HTML templates.

isChecked(true)

// checked

isChecked(false)

// ""

Can also compare string values.

isChecked("admin", "admin")

// checked

Design Goals

This library is designed with the following principles:

  • Zero runtime dependencies
  • High performance
  • Minimal allocations
  • Small bundle size
  • Predictable behavior
  • Browser and Node compatibility

Several implementations avoid regular expressions and repeated string concatenation in favor of allocation-friendly algorithms.


Performance

The library includes optimized implementations for:

  • Manual date parsing
  • Number formatting
  • Integer formatting
  • Phone normalization

Many functions use:

  • single-pass parsing
  • preallocated buffers
  • minimal temporary objects

making them suitable for high-throughput applications.


Browser Support

Works in:

  • Chrome
  • Firefox
  • Safari
  • Edge
  • Node.js
  • Bun
  • Deno

TypeScript

Fully written in TypeScript.

No additional typings are required.