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

direct-helpers

v1.0.3

Published

Package with basic and daily utilities

Readme

📦 Direct Helpers

npm version License TypeScript Bundle Size

A lightweight, zero-dependency TypeScript utility library providing a collection of helper functions for common operations. Perfect for daily development tasks.

📥 Installation

# npm
npm install direct-helpers

# yarn
yarn add direct-helpers

# pnpm
pnpm add direct-helpers

🚀 Usage

// Import the entire library
import * as directHelpers from 'direct-helpers';

// Or import specific modules
import { stringUtils, numberUtils } from 'direct-helpers';

// Or import specific functions directly
import { capitalize } from 'direct-helpers/string';
import { getRandomNumber } from 'direct-helpers/number';

// Examples
stringUtils.capitalize('hello');        // 'Hello'
numberUtils.getRandomNumber(1, 100);    // Random number between 1 and 100

📚 API Reference

🔤 String Utilities

| Function | Description | Example | |----------|-------------|---------| | capitalize(str) | Capitalizes the first letter of a string | capitalize('hello')'Hello' | | capitalizeWords(str) | Capitalizes the first letter of each word | capitalizeWords('hello world')'Hello World' | | countWords(str) | Counts the number of words in a string | countWords('hello world')2 | | countCharacters(str, countWhitespace?) | Counts characters in a string | countCharacters('hello world')10 | | toCamelCase(str) | Converts a string to camel case | toCamelCase('hello-world')'helloWorld' | | toKebabCase(str) | Converts a string to kebab case | toKebabCase('helloWorld')'hello-world' | | toSnakeCase(str) | Converts a string to snake case | toSnakeCase('helloWorld')'hello_world' | | toTitleCase(str) | Converts a string to title case | toTitleCase('hello world')'Hello World' | | generatePassword(length, includeSymbols?) | Generates a random password | generatePassword(8, true)'X7!bP3@z' |

🔢 Number Utilities

| Function | Description | Example | |----------|-------------|---------| | getRandomNumber(min, max) | Generates a random number between min and max | getRandomNumber(1, 10)Random number between 1 and 10 | | getOtp(length?, alphaNumeric?) | Generates a random OTP | getOtp(6)'123456' | | countPercentage(part, total, precision?) | Calculates percentage | countPercentage(25, 100)25.00 | | isEven(number) | Checks if a number is even | isEven(4)true | | isOdd(number) | Checks if a number is odd | isOdd(3)true | | isPrime(number) | Checks if a number is prime | isPrime(7)true | | isPalindrome(number) | Checks if a number is a palindrome | isPalindrome(121)true | | isPerfectSquare(number) | Checks if a number is a perfect square | isPerfectSquare(16)true | | isPerfectCube(number) | Checks if a number is a perfect cube | isPerfectCube(27)true | | square(number) | Squares a number | square(5)25 | | cube(number) | Cubes a number | cube(3)27 | | squareRoot(number) | Calculates the square root of a number | squareRoot(25)5 | | cubeRoot(number) | Calculates the cube root of a number | cubeRoot(27)3 | | factorial(number) | Calculates the factorial of a number | factorial(5)120 | | isPowerOfTwo(number) | Checks if a number is a power of 2 | isPowerOfTwo(8)true | | isPowerOfThree(number) | Checks if a number is a power of 3 | isPowerOfThree(9)true | | roundTo(number, precision) | Rounds a number to a specific precision | roundTo(3.14159, 2)3.14 | | formatNumberWithSuffix(number, precision) | Formats a number with metric suffixes (K, M, B, T) | formatNumberWithSuffix(1500, 1)'1.5K' |

📋 Detailed Documentation

String Utilities

// Capitalize first letter
stringUtils.capitalize('hello');  // 'Hello'

// Capitalize all words
stringUtils.capitalizeWords('hello world');  // 'Hello World'

// Count words
stringUtils.countWords('hello world');  // 2

// Count characters
stringUtils.countCharacters('hello world');  // 10 (without whitespace)
stringUtils.countCharacters('hello world', true);  // 11 (with whitespace)

// Convert to camelCase
stringUtils.toCamelCase('hello-world');  // 'helloWorld'

// Convert to kebab-case
stringUtils.toKebabCase('helloWorld');  // 'hello-world'

// Convert to snake_case
stringUtils.toSnakeCase('helloWorld');  // 'hello_world'

// Convert to title case
stringUtils.toTitleCase('hello world');  // 'Hello World'

// Generate password
stringUtils.generatePassword(8);  // 'Xy7Bcd3z' (without symbols)
stringUtils.generatePassword(8, true);  // 'X7!bP3@z' (with symbols)

Number Utilities

// Generate random number
numberUtils.getRandomNumber(1, 100);  // Random number between 1 and 100

// Generate OTP
numberUtils.getOtp();  // '123456' (default 6-digit numeric)
numberUtils.getOtp(4);  // '1234' (4-digit numeric)
numberUtils.getOtp(6, true);  // 'ab3C9z' (alphanumeric)

// Calculate percentage
numberUtils.countPercentage(25, 100);  // 25.00
numberUtils.countPercentage(25, 100, 0);  // 25

// Check number properties
numberUtils.isEven(4);  // true
numberUtils.isOdd(3);  // true
numberUtils.isPrime(7);  // true
numberUtils.isPalindrome(121);  // true
numberUtils.isPerfectSquare(16);  // true
numberUtils.isPerfectCube(27);  // true

// Mathematical operations
numberUtils.square(5);  // 25
numberUtils.cube(3);  // 27
numberUtils.squareRoot(25);  // 5
numberUtils.cubeRoot(27);  // 3
numberUtils.factorial(5);  // 120

// Power checks
numberUtils.isPowerOfTwo(8);  // true
numberUtils.isPowerOfThree(9);  // true

// Formatting
numberUtils.roundTo(3.14159, 2);  // 3.14
numberUtils.formatNumberWithSuffix(1500, 1);  // '1.5K'
numberUtils.formatNumberWithSuffix(1200000, 2);  // '1.20M'

🖥️ Requirements

  • Node.js 14.x or later
  • TypeScript 4.x or later (for TypeScript projects)

🌐 Browser Compatibility

This package is compatible with modern browsers and Node.js environments.

👥 Contributing

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

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

ISC © Bhargav Tibadiya