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

@g-modules/utils

v1.0.4

Published

Simple helper functions.

Readme

Utils - Simple functions

CodeQL  codecov  codebeat badge

:heavy_exclamation_mark: Important! This module use ES6 import/exports syntax.

Installation and Usage

npm install @g-modules/utils

Also you need to have "type": "module" enavled in your package.json.

Import all functions

import utils from "@g-modules/utils"

const random = utils.randomNumber()

Import some functions

import { randomNumber, randomBool } from "@g-modules/utils"; // import some modules

const random = randomNumber()

Functions:

randomNumber()

Return a random value between the minimum and maximum numbers, inclusive them. Params by default is 0 and 100: randomNumber(0,100).

import { randomNumber } from "@g-modules/utils";

const withoutParams = randomNumber();
console.log(withoutParams); // expect number between 0 and 100

const withParams = randomNumber(10,20);
console.log(withParams); // expect number between 10 and 20

randomBool()

Return a random true/false value. Can be used with chance param, between 0 and 100, where 0 is always false, and 100 is always true.

Default param: randomBool(50).

import { randomBool } from "@g-modules/utils";

const withoutParams = randomBool();
console.log(withoutParams); // expect true with 50% chance

const chance20 = randomBool(20);
console.log(chance20); // expect true with 20% chance

const chance100 = randomBool(100);
console.log(chance100); // expect true with 100% chance

randomId()

Return ID in GUID format (random): xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

import { randomId } from "@g-modules/utils";

const id = randomId();
console.log(id); // expect id string (9bf8ff26-cca2-efa4-a1dc-9ce2928b0770)

uppercaseFirstLetter()

Uppercasing first letter:

import { uppercaseFirstLetter } from "@g-modules/utils";

const original = "hello world!"
const uppercasing = uppercaseFirstLetter(original)
console.log(uppercasing); // expect "Hello world!"

shuffleArray()

Shuffling passed array (Durstenfeld shuffle).

import { shuffleArray } from "@g-modules/utils";

const original = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
const shuffled = shuffleArray(original)
console.log(shuffled) //expect [5, 4, 6, 9, 2, 8, 7, 1, 3, 0]

uniqObjectsInArray()

Leave only unique objects in the array.

import { uniqObjectsInArray } from "@g-modules/utils";

const original = [
	{id: 1, text: "hi!"},
	{id: 2, text: "hello"},
	{id: 3, text: "hi!"}
]
const uniq = uniqObjectsInArray(original, "text") // uniq be "text" key
console.log(uniq) //expect [{ id: 3, text: 'hi!' }, { id: 2, text: 'hello' }

randomElement()

Return random element from Array.

import { randomElement } from "@g-modules/utils";

const array = ["Vue", "React", "Angular"]
const element = randomElement(array)
console.log(element) //expect Vue or React or Angular

randomKey()

Return random key from Object.

import { randomKey } from "@g-modules/utils";

const object = {
	"1": "One",
	"2": "Two",
	"3": "Three"
};
const key = randomKey(object)
console.log(key) //expect "1" or "2" or "3"

randomValue()

Return random value from Object.

import { randomValue } from "@g-modules/utils";

const object = {
	"1": "One",
	"2": "Two",
	"3": "Three"
};
const value = randomValue(object)
console.log(value) //expect "One" or "Two" or "Three"

Developing:

Run docker-compose up