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

@chain1/format-utils

v1.0.0

Published

Number, currency, and date formatting utilities for blockchain applications

Readme

@chain1/format-utils

Number, currency, and date formatting utilities for blockchain applications.

Installation

npm install @chain1/format-utils

Features

  • 📊 Number Formatting: Thousand separators, compact notation (K/M/B)
  • 💰 Currency Formatting: Multi-currency support (KRW, USD, CNY)
  • 📅 Date Formatting: Multiple date formats, timezone handling
  • 🚀 Zero Dependencies: Lightweight and fast
  • 📝 TypeScript Support: Full type definitions included

Usage

Number Formatting

import { numberWithCommas, formatCompactNumber, formatDecimal } from '@chain1/format-utils';

// Add thousand separators
numberWithCommas(1000000); // "1,000,000"
numberWithCommas(1234.56); // "1,234.56"

// Compact notation
formatCompactNumber(1500); // "1.5K"
formatCompactNumber(1500000); // "1.5M"
formatCompactNumber(1500000000); // "1.5B"

// Decimal formatting
formatDecimal(1.23456, 2); // "1.23"
formatDecimal(1.23456, 4); // "1.2346"

Currency Formatting

import { formatDisplayAmount, formatAmount } from '@chain1/format-utils';

// Korean Won (no decimals)
formatDisplayAmount(1000000, 'krw'); // "1,000,000"

// US Dollar (2 decimals)
formatDisplayAmount(1000.5, 'usd'); // "1,000.50"

// Chinese Yuan
formatDisplayAmount(1000.5, 'cny'); // "1,000.50"

// Small amounts (6 decimals for values < 1)
formatDisplayAmount(0.000123, 'usd'); // "0.000123"

Date Formatting

import { formatDate, getTodayTimeRange, isToday } from '@chain1/format-utils';

// Default format
formatDate('2024-11-10T12:30:00Z'); // "2024-11-10 12:30"

// Korean format
formatDate('2024-11-10T12:30:00Z', 'korean'); // "2024년 11월 10일 12:30"

// Short format
formatDate('2024-11-10T12:30:00Z', 'short'); // "11/10 12:30"

// Time only
formatDate('2024-11-10T12:30:00Z', 'time'); // "12:30"

// Date only
formatDate('2024-11-10T12:30:00Z', 'date'); // "2024-11-10"

// Get today's time range
const { startTime, endTime } = getTodayTimeRange();

// Check if date is today
isToday(new Date()); // true

API Reference

Number Utils

numberWithCommas(number: number | string): string

Add thousand separators to a number.

formatDecimal(number: number | string, decimals: number = 2): string

Format number with limited decimal places.

formatCompactNumber(number: number | string): string

Format number in compact notation (K/M/B).

Currency Utils

formatDisplayAmount(amount: number | string, currency: string = 'usd'): string

Format amount based on currency type.

formatAmount(amount: number | string, currency: string = 'usd'): string

Alias for formatDisplayAmount.

Date Utils

formatDate(date: string | Date, format: DateFormat = 'default'): string

Format date to specified format.

Formats:

  • 'default': "YYYY-MM-DD HH:MM"
  • 'korean': "YYYY년 MM월 DD일 HH:MM"
  • 'short': "MM/DD HH:MM"
  • 'time': "HH:MM"
  • 'date': "YYYY-MM-DD"
  • 'korean-date': "YYYY년 MM월 DD일"

getTodayTimeRange(): { startTime: string; endTime: string }

Get today's start and end time as ISO strings.

isToday(date: string | Date): boolean

Check if a date is today.

License

MIT

Author

Stochain

Links