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

@philiprehberger/core-utils

v0.2.9

Published

Pure utility functions - formatting, pagination, slugs, class merging, and more

Downloads

136

Readme

@philiprehberger/core-utils

CI npm version Last updated

Pure utility functions for formatting, pagination, slugs, class merging, and more

Installation

npm install @philiprehberger/core-utils
# Optional peer deps (only needed for cn()):
npm install clsx tailwind-merge

Usage

import {
  formatCurrency,
  generateSlug,
  paginateArray,
  cn,
} from '@philiprehberger/core-utils';

// Format a currency value
const price = formatCurrency(29.99, 'USD'); // "$29.99"

// Generate a URL-friendly slug
const slug = generateSlug('Hello World!'); // "hello-world"

// Paginate an in-memory array
const result = paginateArray(items, 2, 10);
// { data: [...], pagination: { page: 2, limit: 10, total: 100, ... } }

// Merge Tailwind classes (requires clsx + tailwind-merge)
const classes = cn('px-2 py-1', 'px-4'); // "py-1 px-4"

API

Formatting

| Function | Signature | Description | |----------|-----------|-------------| | formatNumber | (value: number, decimals?: number) => string | Locale-aware number formatting with thousand separators. | | formatCurrency | (value: number, currency?: string) => string | Format as currency. Default: 'USD'. | | formatPercentage | (value: number, decimals?: number) => string | Convert decimal to percentage string (0.15 → "15%"). | | formatCompact | (value: number) => string | Compact notation (1234 → "1.2K"). |

Strings

| Function | Signature | Description | |----------|-----------|-------------| | truncate | (text: string, length: number, suffix?: string) => string | Truncate with suffix. Default suffix: "...". | | generateSlug | (text: string) => string | URL-friendly slug from text. | | generateUniqueSlug | (text: string, checkExists: (slug: string) => Promise<boolean>) => Promise<string> | Slug with collision avoidance. | | generateSlugWithDate | (text: string, date?: Date) => string | Date-prefixed slug (YYYY-MM-DD-slug). | | isValidSlug | (slug: string) => boolean | Validate slug format. | | extractSlugFromPath | (path: string) => string | Extract last path segment. |

Pagination

| Function | Signature | Description | |----------|-----------|-------------| | calculatePagination | (page?: number, limit?: number, maxLimit?: number) => { skip, take, page, limit } | Sanitized pagination params. Default limit: 20, max: 100. | | buildPaginationMeta | (page: number, limit: number, total: number) => PaginationMeta | Build metadata from query results. | | createPaginatedResult | <T>(data: T[], page: number, limit: number, total: number) => PaginationResult<T> | Combine data with pagination meta. | | paginateArray | <T>(array: T[], page?: number, limit?: number) => PaginationResult<T> | Paginate an in-memory array. |

Class Merging

| Function | Signature | Description | |----------|-----------|-------------| | cn | (...inputs: ClassValue[]) => string | Merge Tailwind classes. Requires clsx and tailwind-merge peer deps. |

Serialization

| Function | Signature | Description | |----------|-----------|-------------| | serializeObject | <T>(obj: T) => T | Recursively convert Dates to ISO strings. | | deserializeObject | <T>(obj: T) => T | Recursively convert ISO strings back to Dates. |

Async

| Function | Signature | Description | |----------|-----------|-------------| | sleep | (ms: number) => Promise<void> | Delay execution. |

Development

npm install
npm run build
npm test

Support

If you find this project useful:

Star the repo

🐛 Report issues

💡 Suggest features

❤️ Sponsor development

🌐 All Open Source Projects

💻 GitHub Profile

🔗 LinkedIn Profile

License

MIT