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

randbox

v1.0.0

Published

RandBox - Utility library to generate anything random with TypeScript support

Readme

RandBox Modular Structure

This directory contains the modularized version of RandBox, split into separate ES6 modules for better maintainability and tree-shaking support.

Module Structure

Core Module (core.js)

Contains the main RandBox constructor, constants, utility functions, and core dependencies that other modules depend on.

Exports:

  • RandBox - Main constructor
  • Constants: MAX_INT, MIN_INT, NUMBERS, CHARS_LOWER, CHARS_UPPER, HEX_POOL
  • Utilities: initOptions, testRange, range, base64, UnsupportedError

Feature Modules

Each module contains related functionality and can be imported individually:

  1. Basics (basics.js) - Core random generation

    • bool, character, floating, integer, natural, string, buffer, hex
  2. Helpers (helpers.js) - Array and utility functions

    • capitalize, mixin, unique, n, pad, pick, pickone, pickset, shuffle, weighted
  3. Text (text.js) - Text generation

    • paragraph, sentence, syllable, word, emoji
  4. Person (person.js) - People-related data

    • age, birthday, first, last, name, gender, ssn, animal, etc.
  5. Mobile (mobile.js) - Mobile device identifiers

    • android_id, apple_token, wp8_anid2, wp7_anid, bb_pin
  6. Web (web.js) - Web-related data

    • avatar, color, domain, email, ip, url, hashtag, etc.
  7. Location (location.js) - Geographic data

    • address, city, country, coordinates, latitude, longitude, phone, etc.
  8. Finance (finance.js) - Financial data

    • cc, currency, dollar, euro, iban, luhn_check, etc.
  9. Music (music.js) - Music-related data

    • note, chord, tempo, music_genre
  10. Miscellaneous (miscellaneous.js) - Various utilities

    • coin, dice functions (d4, d6, etc.), guid, hash, date functions, normal

Usage

Import Everything (Equivalent to Original)

import RandBox from './src/index.js';
const randBox = new RandBox();
console.log(randBox.name()); // Works exactly like the original

Import Specific Modules (Tree Shaking)

import { RandBox, basicsFunctions } from './src/core.js';
import { name, email } from './src/person.js';

// Use individual functions
console.log(name()); // Direct function call

// Or extend a RandBox instance with specific modules
const randBox = new RandBox();
Object.assign(randBox, { name, email });
console.log(randBox.name());

Import Individual Functions

import { name } from './src/person.js';
import { email } from './src/web.js';
import { natural } from './src/basics.js';

// Use directly (note: 'this' context will need to be bound to a RandBox instance)

Benefits

  1. Tree Shaking: Bundle only the functions you need
  2. Maintainability: Related functions are grouped together
  3. Modularity: Easy to add new modules or modify existing ones
  4. ES6 Compatibility: Modern JavaScript module system
  5. Backwards Compatibility: index.js provides the same API as the original

Dependencies

Each module imports only what it needs from core.js, minimizing dependencies and enabling better optimization.