RandBox Documentation
RandBox is a powerful JavaScript random data generation library, providing a rich API for generating various types of random data. This document covers all of RandBoxโs functional modules and usage methods.
usage - Usage Methods
How to install and use RandBox in different environments:
- bower.mdx - Installation and usage method for the Bower package manager
- browser.mdx - Usage methods in a browser environment (simple, intermediate, advanced)
- requirejs.mdx - RequireJS module loading method
- node.mdx - Installation and usage in a Node.js environment (npm, yarn, ES6)
- function.mdx - Instructions for using custom random functions
- cli.mdx - Command Line Interface installation and usage method
- seed.mdx - Detailed explanation of seed functionality (number, string, multi-parameter seed)
basics - Basic Data Types
Basic data type generation functionality:
- bool.mdx - Generate a random boolean value, supports specifying probability
- character.mdx - Generate a random character, supports options like letters, numbers, symbols
- falsy.mdx - Generate JavaScript falsy values
- floating.mdx - Generate a random floating-point number, supports range and precision settings
- integer.mdx - Generate a random integer, supports minimum and maximum settings
- letter.mdx - Generate a random letter, supports case control
- natural.mdx - Generate a natural number (non-negative integer)
- prime.mdx - Generate a random prime number
- string.mdx - Generate a random string, supports multiple options like length, character pool, case
- template.mdx - Generate a string based on a template, supports placeholder replacement
finance - Financial Data
Financial related data generation functionality:
- cc.mdx - Generate a random credit card number compliant with the Luhn algorithm, supports specifying card type
- cc_type.mdx - Get credit card type information, including full name and abbreviation
- currency.mdx - Generate a random currency code or name
- currency_pair.mdx - Generate a random currency pair
- dollar.mdx - Generate a random US dollar amount, supports maximum value setting
- euro.mdx - Generate a random Euro amount, supports maximum value setting
- exp.mdx - Generate a credit card expiration date (MM/YY format)
- exp_month.mdx - Generate a credit card expiration month (01-12)
- exp_year.mdx - Generate a credit card expiration year, supports 2-digit or 4-digit format
helpers - Helper Tools
Practical helper functions and data manipulation tools:
- capitalize.mdx - Capitalize the first letter of a word
- pick.mdx - Deprecated selection function, recommend using pickone and pickset
- pickset.mdx - Select multiple random elements from an array
- pickone.mdx - Select one random element from an array
- shuffle.mdx - Shuffle the order of an array
- pad.mdx - Number padding functionality
- set.mdx - Override default data sets
- mixin.mdx - Mixin functionality, used to extend RandBox
location - Geographical Location
Geographical location and address related data generation:
- address.mdx - Generate a random street address
- altitude.mdx - Generate a random altitude
- areacode.mdx - Generate a random area code (USA)
- city.mdx - Generate a random city name
- coordinates.mdx - Generate random coordinates (latitude and longitude)
- country.mdx - Generate a random country code or full name
- depth.mdx - Generate a random depth (negative number)
- geohash.mdx - Generate a random geohash
- latitude.mdx - Generate a random latitude
- locale.mdx - Generate a random language code or regional code
- longitude.mdx - Generate a random longitude
- phone.mdx - Generate a random phone number (supports USA, UK, France)
- postal.mdx - Generate a Canadian postal code
- postcode.mdx - Generate a UK postcode
- province.mdx - Generate a random province (supports Canada, Italy)
- state.mdx - Generate a random state (supports USA, Italy)
- street.mdx - Generate a random street name
- zip.mdx - Generate a US ZIP code
miscellaneous - Miscellaneous Tools
Various practical random data generation tools:
- coin.mdx - Coin toss functionality
- dice.mdx - Dice functionality (d4, d6, d8, d10, d12, d20, d30, d100)
- fileWithContent.mdx - Generate a file with random content
- guid.mdx - Generate a random GUID (versions 4 and 5)
- hash.mdx - Generate a random hexadecimal hash
- hidden.mdx - Internal utility methods (credit card types, Mersenne Twister, months, etc.)
- n.mdx - Generate an array of a specified number of random items
- normal.mdx - Normal distribution random number generation
- radio.mdx - Generate a random radio call sign
- rpg.mdx - RPG dice system (e.g., 3d10)
- tv.mdx - Generate a TV station call sign (alias for radio)
- unique.mdx - Generate an array of unique items
- weighted.mdx - Weighted random selection
mobile - Mobile Devices
Mobile device identifier generation:
- android_id.mdx - Generate a random GCM registration ID
- apple_token.mdx - Generate a random Apple Push Token
- bb_pin.mdx - Generate a random BlackBerry device PIN
- wp7_anid.mdx - Generate a random Windows Phone 7 ANID
- wp8_anid2.mdx - Generate a random Windows Phone 8 ANID2
music - Music
Music-related data generation:
- music_genre.mdx - Generate a random music genre, includes 22 main genres and over 600 subgenres
- note.mdx - Generate a random musical note, supports various options (flats, sharps, natural notes, etc.)
- tempo.mdx - Generate a random tempo (default 40-320 BPM)
person - Personal Information
Personal information and identity-related data generation:
- aadhar.mdx - Generate an Indian identity number (Aadhar)
- age.mdx - Generate a random age, supports different types (child, teen, adult, senior)
- birthday.mdx - Generate a random birthday, supports multiple formats and types
- cf.mdx - Generate an Italian social security number (Codice Fiscale)
- cpf.mdx - Generate a Brazilian tax number
- first.mdx - Generate a random first name, supports gender and nationality limits
- gender.mdx - Generate a random gender, supports additional gender options
- last.mdx - Generate a random last name, supports multiple nationalities
- name.mdx - Generate a full random name, supports middle name, prefix, suffix options
- prefix.mdx - Generate a random name prefix (e.g., Mr., Mrs.)
- ssn.mdx - Generate a US Social Security Number
- suffix.mdx - Generate a random name suffix (e.g., Jr., Sr.)
- zodiac.mdx - Generate a random zodiac sign
text - Text Generation
Text and language related content generation:
- emoji.mdx - Generate a random emoji, supports specifying category and length
- paragraph.mdx - Generate a random paragraph, composed of semi-pronounceable nonsense words, supports specifying sentence count and newline option
- sentence.mdx - Generate a random sentence, composed of semi-pronounceable nonsense words, supports specifying word count
- syllable.mdx - Generate semi-pronounceable syllables, used as building blocks for words
- word.mdx - Generate a semi-pronounceable random word, supports specifying syllable count or length (mutually exclusive options)
thing - Entities
Generation of various entities:
- animal.mdx - Generate a random animal name, supports specifying specific types (marine, desert, grassland, forest, farm, pet, zoo)
time - Date and Time
Date and time related data generation:
- ampm.mdx - Generate AM or PM identifier
- date.mdx - Generate a random date, supports multiple formats and specified components
- hammertime.mdx - Generate a Unix timestamp with milliseconds
- hour.mdx - Generate a random hour (12-hour or 24-hour format)
- millisecond.mdx - Generate a random millisecond between 0-999
- minute.mdx - Generate a random minute between 0-59
- month.mdx - Generate a random month, supports raw object format
- second.mdx - Generate a random second between 0-59
- timestamp.mdx - Generate a standard Unix timestamp
- timezone.mdx - Generate a random timezone information object
- weekday.mdx - Generate a weekday, supports limiting to weekdays
- year.mdx - Generate a random year, supports range limits
web - Web Related
Web and internet related data generation:
- avatar.mdx - Generate a Gravatar avatar URL
- color.mdx - Generate a color, supports 6 color formats (hex, rgb, rgba, etc.)
- company.mdx - Generate a random company name
- domain.mdx - Generate a random domain name
- email.mdx - Generate a random email address
- fbid.mdx - Generate a Facebook ID
- google_analytics.mdx - Generate a Google Analytics tracking code
- hashtag.mdx - Generate a random hashtag
- ip.mdx - Generate a random IP address
- ipv6.mdx - Generate a random IPv6 address
- klout.mdx - Generate a Klout score
- mac.mdx - Generate a MAC address
- profession.mdx - Generate a random profession, supports rank options
- tld.mdx - Generate a Top-Level Domain
- twitter.mdx - Generate a Twitter username
- url.mdx - Generate a URL, supports multiple custom options