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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@codevachon/utilities

v1.2.0

Published

A Library Used for managing utilities in Javascript.

Readme

@codevachon/utilities

A Library Used for managing utilities in Javascript.

Install

pnpm add @codevachon/utilities
yarn add @codevachon/utilities
npm install @codevachon/utilities

Usage

asBool

returns the provided values as a boolean value

import { asBool } from "@codevachon/utilities";

if (asBool(process.env.use_thing)) {
    console.log("I can use the thing");
}

isNil

returns the provided values is a undefined or null value

import { isNil } from "@codevachon/utilities";

if (isNil(process.env.use_thing)) {
    console.log("value is underfined or null");
}

isServerSide

check if the code is running on server side.

import { isServerSide } from "@codevachon/utilities";

if (isServerSide()) {
    console.log("run this server side code");
}

returns the value of typeof window === "undefined" && typeof document === "undefined"

slugify

turn a string into a url safe slug

import { slugify } from "@codevachon/utilities";

const mySlug = slugify("Hello World!"); // => `hello-world`

doesKeyExists

Returns if a Key exists on an Object

import { doesKeyExists } from "@codevachon/utilities";

if (doesKeyExists({ foo: "bar" }, "foo")) {
    console.log("key exists on object");
}

sortObjectArrayByKey

Returns an Array of Objects sorted by Key

import { sortObjectArrayByKey } from "@codevachon/utilities";

const sortedArray = sortObjectArrayByKey([{ a: 5 }, { a: 10 }, { a: 1 }], "a");
// sortedArray = [{a: 1},{a: 5},{a: 10}]

capitalize

Returns the string in capitalize case

import { capitalize } from "@codevachon/utilities";

const str = capitalize("banana tree");
// str = "Banana tree"

camelCase

Returns the string in camelCase case

import { camelCase } from "@codevachon/utilities";

const str = camelCase("banana tree");
// str = "bananaTree"

pascalCase

Returns the string in pascalCase case

import { pascalCase } from "@codevachon/utilities";

const str = pascalCase("banana tree");
// str = "BananaTree"

uppercase

Returns the string in upper case

import { uppercase } from "@codevachon/utilities";

const str = uppercase("banana tree");
// str = "BANANA TREE"

lowercase

Returns the string in lowercase case

import { lowercase } from "@codevachon/utilities";

const str = lowercase("banana tree");
// str = "banana tree"

startsWith

Returns the string if starts with a value

import { startsWith } from "@codevachon/utilities";

if (startsWith("banana tree", "ban")) {
    console.log("string starts with ban");
}

endsWith

Returns the string if ends with a value

import { endsWith } from "@codevachon/utilities";

if (endsWith("banana tree", "ban")) {
    console.log("string ends with ban");
}

contains

Returns the string if contains a value

import { contains } from "@codevachon/utilities";

if (contains("banana tree", "ban")) {
    console.log("string contains with ban");
}

invariant

throws an error if the condition is not truthy

import { invariant } from "@codevachon/utilities";

(request: Request, response: Response, next: NextFunction) => {
    invariant(request?.headers?.token, "Expected token to be found on headers");
    // an error is thrown if request.headers.token is not defined
};

randomInt

Generates a random integer with Math.random()

import { randomInt } from "@codevachon/utilities";

const value = randomInt(1, 10);
// value => random number from 1 to 10

randomValueFromArray

Returns a Random index from the provided Array

import { randomValueFromArray } from "@codevachon/utilities";

const value = randomValueFromArray([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
// value => random index from array

randomizeArray

Returns a new array with the indexes in a randomized order

import { randomizeArray } from "@codevachon/utilities";

const value = randomizeArray([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
// value => new array with values in random order

asArray

returns the provided value an array of values

import { asArray } from "@codevachon/utilities";

const value = asArray("a");
// value => ["a"]

range

returns an Array of numbers with with indexes from start to finish

import { range } from "@codevachon/utilities";

const value = range(1, 10);
// value => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

rangeAlpha

returns an Array of characters with with indexes from start to finish

import { rangeAlpha } from "@codevachon/utilities";

const value = rangeAlpha("a", "g");
// value => ["a", "b", "c", "d", "e", "f", "g"]