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

utilsbox

v1.1.6

Published

Utilsbox is your go-to toolkit, offering a wide array of practical utility functions to enhance your application's functionality and streamline development.

Readme

Utilsbox

Utilsbox is your go-to toolkit, offering a wide array of practical utility functions to enhance your application's functionality and streamline development.

Methods

getTime()

Returns the current system time.

const Utils = require("utilsbox");

const time = Utils.getTime();

console.log(`The time is ${time});

getTimeMillis()

Returns the current time represented in milliseconds.

const Utils = require("utilsbox");

const time = Utils.getTimeMillis();

console.log(`The time in milliseconds is ${time});

exitApp(report)

Terminates the application and generates a report in the 'crash_reports' folder within the app directory.

Parameters

  • report: The report detailing the circumstances of the application exit.
const Utils = require("utilsbox");

Utils.exitApp(`Something went wrong!`);

wait(ms)

Delays code execution by a specified duration.

Parameters

  • ms: The duration, in milliseconds, to pause before proceeding with code execution.
const Utils = require("utilsbox");

(async () => {
    console.log("Hello!");
    await Utils.wait(5 * 1000);
    console.log("Hello 5 seconds later!");
})();

repeatWaitUntil(ms, callback)

Waits until the specified callback function returns a true value before continuing execution.

Parameters

  • ms: The time interval, in milliseconds, between successive checks of the callback.
  • callback: The function that will be executed repeatedly until it returns a true value.
const Utils = require("utilsbox");

let a = 0;

(async () => {
    console.log("Hello!");
    await Utils.repeatWaitUntil(1000, async () => {
        if (a >= 10) {
            return true;
        } else {
            a++;
        }
    });
    console.log("'a' is now 10, and it's been 10 seconds!");
})();

findIndex(arr, predicate)

Finds an element within an array based on a provided condition.

Parameters

  • arr: The array to search within.
  • predicate: A function used to test each element of the array.
const Utils = require("utilsbox");

const array = ["hello","bye"];

(async () => {
    const hello = Utils.findIndex(array, (v) => { v === "hello" });
    console.log("'hello' is at index ${hello.index} of the array!");
})();

parseDashedArgs(args)

Converts dashed arguments into a JSON Object.

Parameters

  • args: An array containing dashed arguments to be translated.
const Utils = require("utilsbox");

(async () => {
    const args = Utils.parseDashedArgs(["--a=b"]);
    console.log("Argument 'a' has the value ${args.a}!");
})();

encryptString(key, iv, str)

Encrypts the provided string using the specified encryption key and initialization vector (IV).

Parameters

  • key: The encryption key used to encrypt the given string.
  • iv: The initialization vector (IV) utilized in the encryption process.
  • str: The string to be encrypted using the provided key and IV.
const Utils = require("utilsbox");

(async () => {
	const key = Buffer.from(await Utils.randomString(32)).toString("base64"); // random encryption key

	const iv = Buffer.from(await require("crypto").randomBytes(16)).toString("base64"); // random iv (initialization vector)

	const encrypted_string = await Utils.encryptString(key, iv, "password123");

    console.log(`Encrypted String: ${encrypted_string}`);
})();

decryptString(key, iv, str)

Decrypts the specified string using the provided decryption key and initialization vector (IV).

Parameters

  • key: The decryption key used to decrypt the given string.
  • iv: The initialization vector (IV) used in the decryption process.
  • str: The string to be decrypted using the provided key and IV.
const Utils = require("utilsbox");

(async () => {
	const key = Buffer.from(await Utils.randomString(32)).toString("base64"); // random encryption key

	const iv = Buffer.from(await require("crypto").randomBytes(16)).toString("base64"); // random iv (initialization vector)
	
	const encrypted_string = await Utils.encryptString(key, iv, "password123");

	const decrypted_string = await Utils.decryptString(key, iv, encrypted_string);
	
    console.log(`Decrypted String: ${decrypted_string}`); // Output: password123
})();

hashString(str)

Generates a non-reversible cryptographic hash of the provided string, commonly used for secure storage of passwords and sensitive information.

Parameters

  • str: The string to be hashed for secure storage or comparison purposes.
const Utils = require("utilsbox");

(async () => {
	const hashed_string = await Utils.hashString("password123"); // SHA512

    console.log(`Hashed String: ${hashed_string}`);
})();

randomString(len)

Creates a randomly generated string of the specified length.

Parameters

  • len: The desired length of the generated random string.
const Utils = require("utilsbox");

(async () => {
	const random_string = await Utils.randomString(32);

    console.log(`Random String: ${random_string}`);
})();

randomNumber(len)

Generates a random number within a specified range or with a certain number of digits.

Parameters

  • len: The desired length or range of the generated random number.
const Utils = require("utilsbox");

(async () => {
	const random_number = await Utils.randomNumber(32);

    console.log(`Random Number: ${random_number}`);
})();

getNumberBetween(start, end)

Generates a random number within the specified range.

Parameters

  • start: The lower limit of the desired random number range.
  • end: The upper limit of the desired random number range.
const Utils = require("utilsbox");

(async () => {
	const random_number = await Utils.getNumberBetween(1, 10);

    console.log(`Random Number: ${random_between_number}`);
})();

generateTOTPSecret()

Generates a TOTP secret.

const Utils = require("utilsbox");

(async () => {
	const totp_secret = await Utils.generateTOTPSecret();

    console.log(`TOTP Secret: ${totp_secret}`);
})();

generateTOTPCode(secret)

Generates a Time-Based One-Time Password (TOTP) code using the provided secret.

Parameters

  • secret: The secret key used to generate the Time-Based One-Time Password (TOTP) code.
const Utils = require("utilsbox");

(async () => {
	const totp_secret = await Utils.generateTOTPSecret();

	const current_totp_code = await Utils.generateTOTPCode(totp_secret);

    console.log(`Current TOTP Code: ${current_totp_code}`);
})();