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

@arpansaha13/utils

v0.9.0

Published

A personal collection of utils.

Downloads

247

Readme

Utilities

This package is a compilation of some utility functions that might be needed in general. Some of them are taken from different documentations and articles, and then modified.

Published as @arpansaha13/utils on npm.

General utilities

classNames

  • Alias: cn

A shorthand for twMerge(clsx(...classes)).

classNames('mx-auto max-w-7xl p-4', primary ? 'bg-indigo-600 text-white' : 'bg-transparent text-gray-900')

Note: clsx is imported from clsx/lite.

deepFreeze

Recursively freezes every non-primitive property of an object, preventing modifications to its properties.

const frozenObject = deepFreeze({ a: 1, b: { c: 2 } })
// frozenObject.a = 2; // Error: Cannot assign to read-only property 'a'

isNullOrUndefined

Check if a value is null or undefined.

if (!isNullOrUndefined(variable)) {
  // do something
}

random

Generates a random number between the given min and max values.

random(5, 10)

slugify

slugify('Hello, World!')
// Expected output: "hello-world"

slugify('Hello, Universe!', '_')
// Expected output: "hello_universe"

trim

Removes leading, trailing, and extra whitespace in between a string.

const trimmedString = trim('  Hello,   world!  ')
// trimmedString === "Hello, world!"

clamp

Limits a number to a specified range.

const clampedNumber = clamp(10, 0, 5)
// clampedNumber === 5

truncate

Truncates a string to a specified length and adds an ellipsis.

const truncatedString = truncate('This is a long string', 10)
// truncatedString === "This is a..."

hasLowerCase

Checks if a string contains at least one lowercase character.

const hasLowerCase = hasLowerCase('Hello')
// hasLowerCase === true

uint8ArrayToJson

Convert Uint8Array readable stream to json.

sanitize

Sanitize HTML by escaping special characters in a string.

nFormatter

Format a large number by adding suffixes like "k" and "M".

const formattedNumber = nFormatter(1234567, 2)
// formattedNumber === "1.23M"

getOrdinalSuffix

Returns the appropriate ordinal suffix for that day (e.g., "st" for 1, "nd" for 2, "rd" for 3, and "th" for the rest).

Browser utilities

These utility functions are only meant to be used in the browser and will raise error if used in node.js environment.

getCookie

Returns the value of the cookie if it exists, else returns an empty string.

isTouchDevice

Detect whether the device has a touch screen.

Node utilities

These utility functions are only meant to be used in node.js environment and will raise error if used in the browser environment.

readJsonFile

A shorthand for JSON.parse(await readFile(path, 'utf8')).

readJsonFile('path/to/file')

writeJsonFile

A shorthand for writeFile(path, JSON.stringify(json, null, 2)).

writeJsonFile('path/to/file', { ... })

createEmptyFile

Creates an empty file. If the filePath already exists, an error is thrown.

createEmptyFile('path/to/file')