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

npmtestforazizozenir

v1.0.0

Published

A collection of useful utility functions for strings, numbers, dates, and arrays

Readme

npmtest

A collection of useful utility functions for strings, numbers, dates, and arrays.

Installation

npm install npmtest
# or
pnpm install npmtest
# or
yarn add npmtest

Usage

Import all utilities

import utils from 'npmtest';

// String utilities
utils.slugify('Hello World!'); // 'hello-world'
utils.capitalize('hello'); // 'Hello'
utils.truncate('This is a long string', 10); // 'This is a...'

// Number utilities
utils.formatNumber(1234567); // '1,234,567'
utils.randomNumber(1, 100); // Random number between 1 and 100
utils.clamp(150, 0, 100); // 100

// Date utilities
utils.formatDate(new Date(), 'YYYY-MM-DD'); // '2024-01-15'
utils.getRelativeTime(new Date(Date.now() - 3600000)); // '1 hour ago'
utils.isToday(new Date()); // true

// Array utilities
utils.chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
utils.shuffle([1, 2, 3, 4, 5]); // [3, 1, 5, 2, 4] (random)
utils.unique([1, 2, 2, 3, 3, 3]); // [1, 2, 3]
utils.randomItem([1, 2, 3, 4, 5]); // Random item from array

// General utilities
await utils.delay(1000); // Wait 1 second
utils.deepClone({ a: 1, b: { c: 2 } }); // Deep cloned object
utils.isEmpty(''); // true

Import specific utilities

import { slugify, capitalize, formatNumber, chunk } from 'npmtest';

slugify('Hello World!'); // 'hello-world'
capitalize('hello'); // 'Hello'
formatNumber(1234567); // '1,234,567'
chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]

API Reference

String Utilities

  • slugify(str) - Converts a string to a URL-friendly slug
  • capitalize(str) - Capitalizes the first letter of a string
  • truncate(str, length, suffix?) - Truncates a string to a specified length
  • removeWhitespace(str) - Removes all whitespace from a string
  • reverse(str) - Reverses a string

Number Utilities

  • formatNumber(num, separator?) - Formats a number with thousand separators
  • randomNumber(min, max) - Generates a random number between min and max
  • clamp(num, min, max) - Clamps a number between min and max
  • isEven(num) - Checks if a number is even
  • isOdd(num) - Checks if a number is odd

Date Utilities

  • formatDate(date, format?) - Formats a date to a readable string
  • getRelativeTime(date) - Gets relative time string (e.g., "2 hours ago")
  • isToday(date) - Checks if a date is today

Array Utilities

  • chunk(array, size) - Splits an array into chunks of specified size
  • shuffle(array) - Shuffles an array randomly
  • unique(array) - Removes duplicate values from an array
  • randomItem(array) - Gets a random item from an array
  • groupBy(array, keyFn) - Groups array items by a key function

General Utilities

  • delay(ms) - Delays execution for specified milliseconds (returns Promise)
  • deepClone(obj) - Deep clones an object
  • isEmpty(value) - Checks if a value is empty

Examples

String Manipulation

import { slugify, capitalize, truncate } from 'npmtest';

slugify('Hello World!'); // 'hello-world'
capitalize('hello world'); // 'Hello world'
truncate('This is a very long string', 15); // 'This is a very...'

Number Formatting

import { formatNumber, randomNumber, clamp } from 'npmtest';

formatNumber(1234567.89); // '1,234,567.89'
randomNumber(1, 10); // Random number between 1-10
clamp(150, 0, 100); // 100

Date Operations

import { formatDate, getRelativeTime, isToday } from 'npmtest';

formatDate(new Date(), 'YYYY-MM-DD HH:mm:ss');
getRelativeTime(new Date(Date.now() - 7200000)); // '2 hours ago'
isToday(new Date()); // true

Array Operations

import { chunk, shuffle, unique, groupBy } from 'npmtest';

chunk([1, 2, 3, 4, 5, 6], 2); // [[1, 2], [3, 4], [5, 6]]
shuffle([1, 2, 3, 4, 5]); // Randomly shuffled array
unique([1, 2, 2, 3, 3, 3]); // [1, 2, 3]

const users = [
  { name: 'Alice', age: 25 },
  { name: 'Bob', age: 30 },
  { name: 'Charlie', age: 25 }
];
groupBy(users, user => user.age);
// { 25: [{ name: 'Alice', age: 25 }, { name: 'Charlie', age: 25 }], 30: [{ name: 'Bob', age: 30 }] }

License

ISC