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

@chhanganisab/all-helper-functions

v1.0.6

Published

A collection of 100+ utility functions

Downloads

13

Readme

All Helper Functions

A comprehensive TypeScript utility library with 50+ reusable helper functions for common development tasks. This package provides validation, string manipulation, array operations, object utilities, number utilities, date formatting, and general utility functions.

🚀 Features

  • TypeScript Support: Full TypeScript support with type definitions
  • Zero Dependencies: Lightweight with no external dependencies
  • Tree Shakeable: Import only what you need
  • Well Tested: Reliable and production-ready functions
  • MIT License: Free to use in any project

📦 Installation

npm install @chhanganisab/all-helper-functions
yarn add @chhanganisab/all-helper-functions
pnpm add @chhanganisab/all-helper-functions

🔧 Usage

Import individual functions

import { isValidEmail, capitalize, unique, debounce } from '@chhanganisab/all-helper-functions';

// Validate email
const isValid = isValidEmail('[email protected]'); // true

// Capitalize string
const capitalized = capitalize('hello world'); // 'Hello world'

// Remove duplicates from array
const uniqueArray = unique([1, 2, 2, 3, 3, 4]); // [1, 2, 3, 4]

// Debounce function
const debouncedSearch = debounce((query: string) => {
  // Search logic here
}, 300);

Import all functions

import * as Utils from '@chhanganisab/all-helper-functions';

const isValid = Utils.isValidEmail('[email protected]');
const formatted = Utils.formatDate(new Date(), 'YYYY-MM-DD');

📚 API Reference

🔍 Validators

Email & Communication

  • isValidEmail(email: string): boolean - Validates email format
  • isValidPhoneNumber(phone: string): boolean - Validates phone number format
  • isValidUsername(username: string): boolean - Validates username format

Data Validation

  • isNumeric(value: string): boolean - Checks if string contains only numbers
  • isAlpha(value: string): boolean - Checks if string contains only letters
  • isAlphanumeric(value: string): boolean - Checks if string contains only letters and numbers
  • isAlphaNumericWithSpaces(value: string): boolean - Checks if string contains letters, numbers, and spaces
  • isLowerCase(value: string): boolean - Checks if string is all lowercase
  • isUpperCase(value: string): boolean - Checks if string is all uppercase

Security & Authentication

  • isStrongPassword(password: string): boolean - Validates password strength
  • isBase64(value: string): boolean - Checks if string is valid Base64
  • isAscii(value: string): boolean - Checks if string contains only ASCII characters

Data Formats

  • isJSON(value: string): boolean - Validates JSON string format
  • isUUID(value: string): boolean - Validates UUID format
  • isHexColor(value: string): boolean - Validates hex color format
  • isCreditCard(value: string): boolean - Validates credit card number format
  • isIPAddress(value: string): boolean - Validates IP address format
  • isValidPostalCode(postalCode: string): boolean - Validates postal code format
  • isValidSlug(slug: string): boolean - Validates URL slug format

Content Validation

  • isEmptyString(value: string): boolean - Checks if string is empty or whitespace
  • isValidDate(value: string | Date): boolean - Validates date format
  • isEmoji(value: string): boolean - Checks if string contains emoji characters

🔤 String Utilities

  • capitalize(str: string): string - Capitalizes the first letter of a string
  • camelCase(str: string): string - Converts string to camelCase format
  • kebabCase(str: string): string - Converts string to kebab-case format
  • snakeCase(str: string): string - Converts string to snake_case format
  • pascalCase(str: string): string - Converts string to PascalCase format
  • truncate(str: string, length: number, suffix?: string): string - Truncates string to specified length
  • reverse(str: string): string - Reverses a string
  • debounce<T>(func: T, wait: number): T - Creates a debounced function
  • throttle<T>(func: T, limit: number): T - Creates a throttled function

🔢 Number Utilities

  • clamp(value: number, min: number, max: number): number - Clamps a number between min and max values
  • sum(...numbers: number[]): number - Calculates the sum of numbers
  • random(min: number, max: number): number - Generates a random number between min and max
  • round(num: number, decimals?: number): number - Rounds a number to specified decimal places
  • formatNumber(num: number, locale?: string): string - Formats a number with locale

📅 Date Utilities

  • formatDate(date: Date, format: string): string - Formats date according to specified format
  • addDays(date: Date, days: number): Date - Adds specified number of days to a date
  • isToday(date: Date): boolean - Checks if date is today
  • daysBetween(date1: Date, date2: Date): number - Calculates days between two dates

📋 Array Utilities

  • unique<T>(arr: T[]): T[] - Removes duplicate values from array
  • chunk<T>(arr: T[], size: number): T[][] - Splits array into chunks of specified size
  • flatten<T>(arr: (T | T[])[]): T[] - Flattens nested arrays
  • shuffle<T>(arr: T[]): T[] - Shuffles array elements randomly
  • groupBy<T, K>(arr: T[], key: keyof T | ((item: T) => K)): Record<K, T[]> - Groups array by key
  • intersection<T>(arr1: T[], arr2: T[]): T[] - Returns common elements between arrays
  • difference<T>(arr1: T[], arr2: T[]): T[] - Returns elements in arr1 but not in arr2

📦 Object Utilities

  • isEmpty(obj: any): boolean - Checks if object is empty
  • deepClone<T>(obj: T): T - Creates a deep clone of an object
  • pick<T, K extends keyof T>(obj: T, keys: K[]): Pick<T, K> - Picks specified keys from object
  • omit<T, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> - Omits specified keys from object
  • merge<T, U>(target: T, source: U): T & U - Deep merges two objects

🛠️ General Utilities

  • memoize<T>(func: T): T - Creates a memoized version of a function
  • retry<T>(fn: () => Promise<T>, maxAttempts?: number, delay?: number): Promise<T> - Retries async function
  • sleep(ms: number): Promise<void> - Creates a delay for specified milliseconds

💡 Examples

Form Validation

import { 
  isValidEmail, 
  isStrongPassword, 
  isValidPhoneNumber 
} from '@chhanganisab/all-helper-functions';

const validateForm = (formData: any) => {
  const errors = [];
  
  if (!isValidEmail(formData.email)) {
    errors.push('Invalid email address');
  }
  
  if (!isStrongPassword(formData.password)) {
    errors.push('Password is not strong enough');
  }
  
  if (!isValidPhoneNumber(formData.phone)) {
    errors.push('Invalid phone number');
  }
  
  return errors;
};

Data Processing

import { 
  unique, 
  chunk, 
  capitalize, 
  formatDate,
  groupBy,
  shuffle
} from '@chhanganisab/all-helper-functions';

// Process user data
const users = [
  { name: 'john doe', email: '[email protected]', role: 'admin' },
  { name: 'jane smith', email: '[email protected]', role: 'user' },
  { name: 'john doe', email: '[email protected]', role: 'admin' } // duplicate
];

// Remove duplicates and format names
const processedUsers = unique(users.map(user => user.email))
  .map(email => users.find(u => u.email === email))
  .map(user => ({
    ...user,
    name: capitalize(user.name)
  }));

// Group by role
const usersByRole = groupBy(processedUsers, 'role');

// Shuffle for random order
const shuffledUsers = shuffle(processedUsers);

// Split into chunks for pagination
const userChunks = chunk(processedUsers, 10);

// Format current date
const today = formatDate(new Date(), 'YYYY-MM-DD');

Object Manipulation

import { 
  isEmpty, 
  deepClone,
  pick,
  omit,
  merge
} from '@chhanganisab/all-helper-functions';

const originalObject = {
  user: {
    name: 'John',
    email: '[email protected]',
    preferences: {
      theme: 'dark',
      notifications: true
    }
  },
  settings: {},
  metadata: {
    createdAt: new Date(),
    version: '1.0.0'
  }
};

// Check if settings object is empty
if (isEmpty(originalObject.settings)) {
  console.log('Settings object is empty');
}

// Pick only user data
const userData = pick(originalObject, ['user']);

// Omit sensitive data
const publicData = omit(originalObject, ['metadata']);

// Create a deep clone for safe modification
const clonedObject = deepClone(originalObject);
clonedObject.user.preferences.theme = 'light';

// Merge with new settings
const updatedObject = merge(originalObject, {
  user: { preferences: { theme: 'light' } },
  settings: { debug: true }
});

Performance Optimization

import { 
  debounce, 
  throttle, 
  memoize,
  retry,
  sleep
} from '@chhanganisab/all-helper-functions';

// Debounced search
const debouncedSearch = debounce((query: string) => {
  console.log('Searching for:', query);
  // API call here
}, 300);

// Throttled scroll handler
const throttledScroll = throttle(() => {
  console.log('Scroll position:', window.scrollY);
}, 100);

// Memoized expensive calculation
const expensiveCalculation = memoize((n: number) => {
  console.log('Calculating...');
  return n * n * n;
});

// Retry API call
const fetchData = async () => {
  return await retry(
    async () => {
      const response = await fetch('/api/data');
      if (!response.ok) throw new Error('API failed');
      return response.json();
    },
    3, // max attempts
    1000 // delay between attempts
  );
};

// Sleep utility
const delayedAction = async () => {
  console.log('Starting...');
  await sleep(2000); // wait 2 seconds
  console.log('Finished!');
};

String Manipulation

import { 
  capitalize, 
  camelCase, 
  kebabCase, 
  snakeCase, 
  pascalCase,
  truncate,
  reverse
} from '@chhanganisab/all-helper-functions';

const text = 'hello world example';

console.log(capitalize(text)); // 'Hello world example'
console.log(camelCase(text)); // 'helloWorldExample'
console.log(kebabCase(text)); // 'hello-world-example'
console.log(snakeCase(text)); // 'hello_world_example'
console.log(pascalCase(text)); // 'HelloWorldExample'
console.log(truncate(text, 10)); // 'hello wo...'
console.log(reverse(text)); // 'elpmaxe dlrow olleh'

🤝 Contributing

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

📄 License

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

👨‍💻 Author

Chhanganisab - LinkedIn

⭐ Support

If you find this library helpful, please consider giving it a star on GitHub!


Made with ❤️ for the developer community