-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.ts
35 lines (30 loc) · 824 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import {
randomAge,
randomFirstName,
randomLastName,
randomBirthDate,
nameToEmail,
randomPhone,
processOptions
} from "./src/functions";
/**
* Return user object { name, email, age, birthDate, phone }
* @param gender "male" for male names or "female" for female names
* @param minAge Minimun Age
* @param genre Maximun Age
*/
export function randomUser(options?: {
genre?: "male" | "female";
minAge?: number;
maxAge?: number;
}) {
const { gender, minAge, maxAge } = processOptions(options);
const name = `${randomFirstName(gender)} ${randomLastName()}`;
const email = nameToEmail(name);
const age = randomAge(minAge, maxAge);
const birthDate = randomBirthDate(age);
const phone = randomPhone();
const user = { name, email, age, birthDate, phone };
return user;
}
module.exports = { randomUser };