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

@sk2you/custom-utils

v1.0.7

Published

A collection of utility functions for TypeScript projects

Readme

JavaScript/TypeScript Utility Functions

This repository contains a collection of useful JavaScript/TypeScript utility functions for common tasks like date formatting, pagination, and number formatting.

Table of Contents

Installation

# Using npm
npm install @yourpackage/utils

# Using yarn
yarn add @yourpackage/utils

Functions

Date Formatting

Format UNIX timestamps into readable date strings with customizable options.

getFormattedDate(
  UNIX_timestamp: number | string, 
  types: string[], 
  symbol = '-', 
  timeSeparator = ':', 
  timeFormat = '24', 
  monthName = false, 
  includeDay = true
): string

Parameters:

  • UNIX_timestamp: The UNIX timestamp to format
  • types: Array of elements to include ('day', 'date', 'month', 'year', 'hour', 'minute', 'second', 'period')
  • symbol: Symbol to use as separator between date elements (default: -)
  • timeSeparator: Symbol to use as separator between time elements (default: :)
  • timeFormat: '12' for 12-hour format with am/pm, '24' for 24-hour format (default: '24')
  • monthName: Whether to show month as name (Jan, Feb) instead of number (default: false)
  • includeDay: Whether to include the day name (SUN, MON, etc.) (default: true)

Pagination

Calculate page count based on pagination parameters.

GetPageCount(pagination: PaginationParams, index: number): number

Parameters:

  • pagination: Object containing limit and page properties
  • index: Current index

Number to Words

Convert numbers to their word representation with support for both Western and Indian number systems.

numberToWords(num: number, useIndianSystem = false): string

Parameters:

  • num: The number to convert to words
  • useIndianSystem: Whether to use Indian number naming (lakh, crore) (default: false)

Number Formatting

Format numbers with Indian numbering system separators.

formatNumberWithIndianSeparators(
  num: number | string, 
  separator = ',', 
  includeWords = false
): string

Parameters:

  • num: The number to format
  • separator: The separator character (default: ,)
  • includeWords: Whether to include the Indian names (lakh, crore) in parentheses (default: false)

Usage Examples

Date Formatting

import { getFormattedDate } from '@yourpackage/utils';

// Basic date formatting
const timestamp = 1618990800000; // April 21, 2021
const formattedDate = getFormattedDate(timestamp, ['date', 'month', 'year']);
console.log(formattedDate); // "21-04-2021"

// With month names and custom separator
const prettyDate = getFormattedDate(timestamp, ['date', 'month', 'year'], '/', undefined, undefined, true);
console.log(prettyDate); // "21/Apr/2021"

// With time
const dateTime = getFormattedDate(timestamp, ['date', 'month', 'year', 'hour', 'minute'], '-', ':', '12', true);
console.log(dateTime); // "21-Apr-2021 12:00"

Pagination

import { GetPageCount } from '@yourpackage/utils';

const pagination = { limit: 10, page: 2 };
const itemIndex = 3;

const pageCount = GetPageCount(pagination, itemIndex);
console.log(pageCount); // 14 (10 + 3 + 1)

Number to Words

import { numberToWords } from '@yourpackage/utils';

// Western system
console.log(numberToWords(123)); // "one hundred twenty-three"
console.log(numberToWords(1000000)); // "one million"

// Indian system
console.log(numberToWords(100000, true)); // "one lakh"
console.log(numberToWords(10000000, true)); // "one crore"

Number Formatting

import { formatNumberWithIndianSeparators } from '@yourpackage/utils';

// Basic formatting
console.log(formatNumberWithIndianSeparators(123456)); // "1,23,456"
console.log(formatNumberWithIndianSeparators(10000000)); // "1,00,00,000"

// With Indian number names
console.log(formatNumberWithIndianSeparators(100000, ',', true)); // "1,00,000 (1 lakh)"
console.log(formatNumberWithIndianSeparators(20000000, ',', true)); // "2,00,00,000 (2 crores)"

License

This project is licensed under the MIT License - see the LICENSE file for details.