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

utility-sdk

v1.0.5

Published

A lightweight TypeScript utility SDK

Readme

Utility SDK

A lightweight and developer-friendly utility SDK for Node.js and TypeScript projects. It includes string manipulation, date/time formatting, validation, hashing, and HTTP helper functions — all with minimal dependencies.


📦 Installation

npm install utility-sdk

📚 Usage

import { capitalize, isEmail, formatDate, debounce } from 'utility-sdk';

console.log(capitalize('hello world')); // Hello world
console.log(isEmail('[email protected]')); // true
console.log(formatDate(new Date()));     // 2025-07-31 (example)

// Example: debounce
const logMessage = debounce((msg: string) => console.log(msg), 300);
logMessage("Hello");

🧰 Utilities Overview

📅 Date Utilities (date.ts)

isPast24Hours(dateOrTimestamp: Date | number): boolean → Checks if a given date is within the last 24 hours.

isToday(dateOrTimestamp: Date | number): boolean → Determines if a date is today.

formatDate(dateOrTimestamp: Date | number, separator = '-'): string → Formats a date to YYYY-MM-DD.

isWeekend(dateOrTimestamp: Date | number): boolean → Returns true if the date falls on a weekend.

daysBetween(start: Date | number, end: Date | number): number → Calculates how many days are between two dates.

getTimeAgo(dateOrTimestamp: Date | number): string → Returns a relative time ago string (e.g. "5 minutes ago").


🔐 Hashing Utilities (hashing.ts)

generateUUID(): string → Generates a unique UUID v4.

hashString(input: string): string → Returns a SHA-256 hash of the string.


🔧 Helper Utilities (helper.ts)

GenerateSeriesId(prefix = '', length = 8): string → Creates a custom ID with optional prefix.

log(message: any): void → Logs with timestamp.

isEmail(input: string): boolean → Validates email format.

isURL(input: string): boolean → Validates URL format.

isPhoneNumber(input: string): boolean → Validates phone number format.

isEmpty(value: any): boolean → Checks if a value is null, undefined, or empty.


📑 Pagination & Search (pagination.ts)

paginate(data, { page, limit }) → Returns a paginated subset of the data.

search(keyword, { field?, searchBy? }) → Deep search in the dataset.

sort(compareFn) → Custom sorting on processed results.

getData() → Returns the processed (filtered/paginated/sorted) data.

reset() → Resets state to original dataset.


⏳ Function Control Utilities (optimization.ts)

debounce(fn: Function, delay: number): Function → Delays execution until after a pause in calls.

debouncePromise(fn: Function, delay: number): Function → Debounced function that returns a Promise.

deepGet(path: string, data: any): any → Retrieves nested values using dot notation.


🔑 JWT Utilities (jwt-manager.ts)

decodePayload(token: string): object | null → Decodes JWT payload without verifying signature.

sign(payload: object, options?): string | null → Signs a new JWT token.

verify(token: string, secret: string): boolean → Verifies a JWT token.

refreshToken(refreshToken: string, expiresIn = '15m'): string | null → Creates a new token from a refresh token.

validateRefreshToken(refreshToken: string): object | null → Validates and decodes refresh token.

handleRefreshRequest(refreshToken: string, expiresIn = '15m'): { success, token, error } → Handles refresh token flow.


🌐 HTTP Utilities (http.ts)

httpRequest(method: 'GET' | 'POST', url: string, options: { params?, queryParams?, body?, headers? }): Promise → Wrapper around Axios for GET and POST requests. → Automatically returns .data from the response.


🔢 Number Utilities (number.ts)

isEven(n: number): boolean → Checks if a number is even.

isOdd(n: number): boolean → Checks if a number is odd.

roundTo(num: number, decimals: number): number → Rounds a number to a fixed number of decimal places.

toPercent(value: number, total: number): string → Returns percentage string based on total.

formatWithCommas(num: number): string → Formats number with thousand separators.

groupedSumByNested(data: any[], groupByPaths: string[], sumPath: string, statusPath?: string, statusValue?: any): any → Multi-level grouping and summing.


🔠 String Utilities (string.ts)

capitalize(str: string): string → Capitalizes the first letter.

toPascalCase(str: string): string → Converts to PascalCase.

truncate(str: string, maxLength: number): string → Trims and adds ... when exceeding max length.

checkIfPureString(str: string, allowWhiteSpace = false): boolean → Checks if a string contains only alphabetic characters (with optional whitespace).


🛡️ License

MIT License