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

@devt110103/utils-js

v1.3.2

Published

A simple utility library for JavaScript and TypeScript

Readme

@devt110103/utils-js

A comprehensive utility library for JavaScript and TypeScript with full type support.

Installation

npm install @devt110103/utils-js

Features

  • Full TypeScript Support - Complete type definitions for perfect IntelliSense
  • 🌍 Number Formatting - Locale-aware number formatting with currency, percent, and custom options
  • 📅 Date Formatting - Comprehensive date formatting with dayjs integration
  • 📦 Zero Configuration - Works out of the box with sensible defaults
  • 🔧 Highly Customizable - Extensive options for advanced use cases

Usage

Number Formatting

import { formatNumber } from '@devt110103/utils-js';

// Basic usage with locale
formatNumber(1234.56, 'vi-VN');        // "1.234,56"
formatNumber(1234.56, 'en-US');        // "1,234.56"

// Currency formatting
formatNumber(1234.56, {
  style: 'currency',
  currency: 'VND',
  locale: 'vi-VN'
});  // "1.235 ₫"

formatNumber(1234.56, {
  style: 'currency',
  currency: 'USD',
  locale: 'en-US'
});  // "$1,234.56"

// Percentage formatting
formatNumber(0.1234, {
  style: 'percent',
  minimumFractionDigits: 2
});  // "12.34%"

// Custom decimal places
formatNumber(1234.56789, {
  minimumFractionDigits: 2,
  maximumFractionDigits: 3
});  // "1,234.568"

Date Formatting

import { formatDate } from '@devt110103/utils-js';

const date = new Date('2025-08-01T14:30:00');

// Basic formats
formatDate(date, 'YYYY-MM-DD');              // "2025-08-01"
formatDate(date, 'DD/MM/YYYY');              // "01/08/2025"
formatDate(date, 'MM/DD/YYYY');              // "08/01/2025"

// With time
formatDate(date, 'YYYY-MM-DD HH:mm:ss');     // "2025-08-01 14:30:00"
formatDate(date, 'DD/MM/YYYY h:mm A');       // "01/08/2025 2:30 PM"

// Long formats
formatDate(date, 'MMMM D, YYYY');            // "August 1, 2025"
formatDate(date, 'dddd, MMMM D, YYYY');      // "Friday, August 1, 2025"

// ISO formats
formatDate(date, 'YYYY-MM-DDTHH:mm:ss');     // "2025-08-01T14:30:00"

// Custom format (any dayjs format)
formatDate(date, 'YYYY年MM月DD日');           // "2025年08月01日"

TypeScript Support

This library is written in TypeScript and provides full type definitions. When you install the package, you'll get:

  • IntelliSense - Auto-completion for all function parameters
  • Type Safety - Compile-time checking for correct usage
  • Documentation - Hover tooltips with parameter descriptions
  • Format Suggestions - Auto-complete for date format strings

Example with TypeScript

import { formatNumber, formatDate } from '@devt110103/utils-js';

// TypeScript will provide auto-completion for format strings
const formatted = formatDate(new Date(), 'YYYY-MM-DD'); // ✅ Suggested formats
const number = formatNumber(1234.56, {
  style: 'currency', // ✅ Auto-complete: 'decimal' | 'currency' | 'percent' | 'unit'
  currency: 'USD'    // ✅ Type-safe
});

API Reference

formatNumber(value, options?)

Formats a number with locale and style options.

Parameters:

  • value: number - The number to format
  • options?: string | object - Locale string or formatting options

Options Object:

  • locale?: string - BCP 47 language tag (e.g., 'en-US', 'vi-VN')
  • style?: 'decimal' | 'currency' | 'percent' | 'unit' - Number formatting style
  • currency?: string - Currency code (e.g., 'USD', 'VND') - required when style is 'currency'
  • unit?: string - Unit identifier (e.g., 'kilometer') - required when style is 'unit'
  • minimumFractionDigits?: number - Minimum number of decimal places
  • maximumFractionDigits?: number - Maximum number of decimal places
  • useGrouping?: boolean - Whether to use grouping separators

formatDate(date, format)

Formats a date using dayjs with comprehensive format options.

Parameters:

  • date: Date - The date to format
  • format: string - Format string (with auto-completion for common patterns)

Common Format Patterns:

  • YYYY-MM-DD - ISO date format
  • DD/MM/YYYY - European date format
  • MM/DD/YYYY - US date format
  • MMMM D, YYYY - Long format with month name
  • dddd, MMMM D, YYYY - Full format with day name
  • And many more...

License

MIT

Author

DevT (@devt110103)