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

@ruxandrafed/simple-utils

v1.2.7

Published

A simple utility package with common helper functions

Readme

@ruxandrafed/simple-utils

A simple utility package with common helper functions for JavaScript/TypeScript projects.

Installation

npm install @ruxandrafed/simple-utils

Usage

import { 
  capitalize, 
  randomString, 
  isValidEmail, 
  formatCurrency, 
  debounce, 
  sleep,
  deepClone,
  formatDate,
  addDaysToDate,
  daysDifference,
  isDateAfter,
  isDateBefore,
  generateId,
  removeDuplicates,
  chunk
} from '@ruxandrafed/simple-utils';

// Capitalize first letter
console.log(capitalize('hello world')); // "Hello world"

// Generate random string
console.log(randomString(10)); // "aB3xY9mK2p"

// Validate email
console.log(isValidEmail('[email protected]')); // true

// Format currency
console.log(formatCurrency(1234.56)); // "$1,234.56"

// Deep clone objects
const original = { a: 1, b: { c: 2 } };
const cloned = deepClone(original);

// Format dates
console.log(formatDate(new Date())); // "2023-12-25"
console.log(formatDate(new Date(), 'dd/MM/yyyy')); // "25/12/2023"

// Date operations
const tomorrow = addDaysToDate(new Date(), 1);
const daysDiff = daysDifference(new Date('2023-12-30'), new Date('2023-12-25')); // 5

// Generate unique IDs
console.log(generateId()); // "1"
console.log(generateId('user')); // "user_2"

// Remove duplicates
console.log(removeDuplicates([1, 2, 2, 3, 3, 4])); // [1, 2, 3, 4]

// Split array into chunks
console.log(chunk([1, 2, 3, 4, 5, 6], 2)); // [[1, 2], [3, 4], [5, 6]]

// Debounce function calls
const debouncedFn = debounce(() => {
  console.log('This will only run once after 300ms of inactivity');
}, 300);

// Sleep for 1 second
await sleep(1000);

API Reference

capitalize(str: string): string

Capitalizes the first letter of a string.

randomString(length?: number): string

Generates a random string of specified length (default: 8).

isValidEmail(email: string): boolean

Checks if a string is a valid email address.

formatCurrency(amount: number, currency?: string): string

Formats a number as currency (default currency: 'USD').

debounce(func: Function, delay: number): Function

Creates a debounced version of a function that delays execution.

sleep(ms: number): Promise

Returns a promise that resolves after the specified number of milliseconds.

deepClone(obj: T): T

Deep clones an object using lodash.

formatDate(date: Date, formatStr?: string): string

Formats a date using date-fns (default format: 'yyyy-MM-dd').

addDaysToDate(date: Date, days: number): Date

Adds days to a date and returns a new Date object.

daysDifference(date1: Date, date2: Date): number

Calculates the difference in days between two dates.

isDateAfter(date: Date, compareDate: Date): boolean

Checks if a date is after another date.

isDateBefore(date: Date, compareDate: Date): boolean

Checks if a date is before another date.

generateId(prefix?: string): string

Generates a unique ID using lodash (optionally with a prefix).

removeDuplicates(array: T[]): T[]

Removes duplicates from an array using lodash.

chunk(array: T[], size: number): T[][]

Splits an array into chunks of specified size using lodash.

Dependencies

This package includes the following dependencies:

  • lodash: For utility functions like deep cloning and array operations
  • date-fns: For date manipulation and formatting

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.