Comprehensive random data generation utilities for testing and development.

RandomGenerator provides a collection of functions for generating random data including strings, names, content, dates, and array sampling. All functions are designed to be deterministic within a single execution but produce varied output across different runs, making them ideal for testing scenarios.

The namespace includes specialized generators for:

  • Text content (alphabets, alphanumeric, names, paragraphs)
  • Phone numbers and contact information
  • Date ranges and time-based data
  • Array sampling and element selection

Jeongho Nam - https://github.com/samchon

  // Generate test user data
const testUser = {
id: RandomGenerator.alphaNumeric(8),
name: RandomGenerator.name(),
bio: RandomGenerator.paragraph(3)(5, 10),
phone: RandomGenerator.mobile(),
createdAt: RandomGenerator.date(new Date())(1000 * 60 * 60 * 24 * 30) // 30 days
};

// Sample data for testing
const testSample = RandomGenerator.sample(allUsers)(5);

Functions

alphabets
alphaNumeric
content
date
mobile
name
paragraph
pick
sample
substring