real-name-gen
v1.0.0
Published
A lightweight Node.js package to generate realistic human names based on regions.
Maintainers
Readme
real-name-gen
A lightweight, zero-dependency Node.js package to generate realistic human names. Supports regional Indian names, gender filtering, initials, and seeded random generation for reproducibility.
Installation
npm install real-name-genUsage
const rn = require("real-name-gen"); // Assuming you use this exact name
// 1. Basic Usage
console.log(rn.fullName());
// => "Rajesh Rajan"
// 2. Generate multiple names
console.log(rn.fullName("normal", 3));
// => [ 'Ravi Rajan', 'Virat Chandran', 'Divya Patel' ]
// 3. Generate names with initials
console.log(rn.fullName("initial"));
// => "A. Karthik Das"
// 4. Region filtering ("india", "tamil", "north-india")
console.log(rn.fullName("normal", 1, "tamil"));
// => "Vignesh Subramanian"
// 5. Gender filtering ("male", "female", "any")
console.log(rn.fullName("normal", 1, "any", "female"));
// => "Sneha Iyer"
// 6. Set a seed for reproducible results
rn.setSeed(42);
console.log(rn.fullName());
rn.setSeed(42);
console.log(rn.fullName()); // Will print the exact same name as aboveAPI Functions
All generation functions share the same signature:
(format = "normal", count = 1, region = "any", gender = "any")
fullName(...): Generates a full name (first + last).firstName(...): Generates only a first name.lastName(...): Generates only a last name.setSeed(seed): Sets the random generation seed (Accepts Numbers or Strings).
Parameters
| Parameter | Type | Default | Options |
|-----------|------|---------|---------|
| format | String | "normal" | "normal", "initial" |
| count | Number | 1 | Any positive integer. (If >1, returns an array) |
| region | String | "any" | "any", "india", "tamil", "north-india" |
| gender | String | "any" | "any", "male", "female" |
License
ISC
