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

ts-utix

v1.0.3

Published

A lightweight utility library for TypeScript and JavaScript

Readme

TS-UTIX

Utility Functions Collection

A set of useful utility functions for formatting numbers, strings, dates, and generating UUIDs.

Installation

npm install ts-utix

Usage

import { formatNumber, kebabCase, UUID, relativeTime, getEmails } from 'ts-utix';

API Reference

1. Numbers

formatNumber(num: number, unit?: "K" | "M" | "B" | "") => string

Formats numbers with optional unit suffixes (K, M, B).

formatNumber(1500);       // "1.5K"
formatNumber(2500000);    // "2.5M"
formatNumber(3140000000); // "3.1B"
formatNumber(900, "K");   // "900" (doesn't reach 1K)
formatNumber(2500, "K");  // "2.5K"

2. Stirngs

kebabCase(str: string) => string

Converts strings to kebab-case format.

kebabCase("HelloWorld");     // "hello-world"
kebabCase("someMixed_string"); // "some-mixed-string"
kebabCase("GET_DATA_FROM_API"); // "get-data-from-api"

UUID() => string

Generates RFC 4122 compliant UUID v4.

UUID(); // e.g. "f47ac10b-58cc-4372-a567-0e02b2c3d479"

getEmails() => string[]

Get all the emails from an text

getEmails(text: string, domains?: string[]) => string[]

const text = "Contact [email protected] and [email protected] for help.";
console.log(getEmails(text)); // ["[email protected]", "[email protected]"]
console.log(getEmails(text, ["sanjeet.com"]));
// ["[email protected]"]
console.log(getEmails(text, ["sanjeet.com", "gmail.com"]));
// ["[email protected]", "[email protected]"]

3. Date And Time

a. relativeTime(date: Date) => string

Returns human-readable relative time strings.

import { formatDate, timeAgo, isLeapYear, getDaysInMonth, addDays, timeDifference, timestampToDate } from 'ts-utix'

b. formatDate(date: Date | string | number , format: "YYYY-MM-DD HH-mm-ss") => string

console.log(formatDate("2025-03-02", "YYYY-MM-DD")); // "2025-03-02"
console.log(formatDate(new Date(), "DD/MM/YYYY HH:mm:ss")); // "02/03/2025 14:30:45" (example output)

c. timeAgo(input: Date | string | number) => string

console.log(timeAgo(new Date(Date.now() - 1000 * 60 * 60 * 24 * 2))); // "2 days ago"
console.log(timeAgo(new Date(Date.now() + 1000 * 60 * 60 * 5))); // "in 5 hours"

d. isLeapYear(input: Date | number)

console.log(isLeapYear(2024)); // true
console.log(isLeapYear(new Date)); // 2025 => false

e. getDaysInMonth(input : Date | number , month?: number ) => number

console.log(getDaysInMonth(2025, 2)); // 28 (February 2025)
console.log(getDaysInMonth(new Date(2025, 3, 15))); // 30 (April 2025)
console.log(getDaysInMonth(new Date())); // Returns days in the current getDaysInMonth

f. addDays(input: Date | string | number, days: number) => string | Date

console.log(addDays("2025-03-02", 10)); // "2025-03-12"
console.log(addDays(new Date(), -5)); // Date 5 days package-lock.json

g. timeDifference(input1: Date | string | number, input2: Date | string | number) =>

console.log(timeDifference("2025-03-02", "2025-03-05")); // { days: 3, hours: 0, minutes: 0, seconds: 0 }
console.log(timeDifference(new Date(), new Date(Date.now() + 1000 * 60 * 60 * 24 * 7))); // { days: 7, hours: 0, minutes: 0, seconds: 0 }

Features

  • Zero dependencies
  • TypeScript support
  • Browser and Node.js compatible
  • Comprehensive type definitions
  • 100% test coverage

Requirements

  • ECMAScript 2015 (ES6) or newer
  • Node.js 20+ or modern browser