Skip to content

Commit d651e5f

Browse files
committed
Merge branch 'next' into 1348-refactor-mersenne
2 parents 58e7b39 + 20f2236 commit d651e5f

File tree

593 files changed

+1173
-1112
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

593 files changed

+1173
-1112
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ The API covers the following modules:
8888
| Internet | `faker.internet.domainName()` | muddy-neuropathologist.net |
8989
| Lorem | `faker.lorem.paragraph()` | Porro nulla id vero perspiciatis nulla nihil. ... |
9090
| Music | `faker.music.genre()` | R&B |
91-
| Name | `faker.name.firstName()` | Cameron |
91+
| Person | `faker.person.firstName()` | Cameron |
9292
| Phone | `faker.phone.phoneNumber()` | +1 291-299-0192 |
9393
| Random | `faker.random.locale()` | fr_CA |
9494
| Science | `faker.science.unit()` | `{ name: 'meter', symbol: 'm' }` |
@@ -103,7 +103,7 @@ Faker contains a generator method `faker.helpers.fake` for combining faker API m
103103
```ts
104104
console.log(
105105
faker.helpers.fake(
106-
'Hello {{name.prefix}} {{name.lastName}}, how are you today?'
106+
'Hello {{person.prefix}} {{person.lastName}}, how are you today?'
107107
)
108108
);
109109
```

docs/.vitepress/api-pages.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const apiPages = [
1818
{ text: 'Internet', link: '/api/internet.html' },
1919
{ text: 'Lorem', link: '/api/lorem.html' },
2020
{ text: 'Music', link: '/api/music.html' },
21-
{ text: 'Name', link: '/api/name.html' },
21+
{ text: 'Person', link: '/api/person.html' },
2222
{ text: 'Phone', link: '/api/phone.html' },
2323
{ text: 'Random', link: '/api/random.html' },
2424
{ text: 'Science', link: '/api/science.html' },

docs/guide/usage.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Using Faker is as easy as importing it from `@faker-js/faker`.
77
```js
88
import { faker } from '@faker-js/faker';
99

10-
const randomName = faker.name.fullName(); // Rowan Nikolaus
10+
const randomName = faker.person.fullName(); // Rowan Nikolaus
1111
const randomEmail = faker.internet.email(); // [email protected]
1212
```
1313

@@ -16,7 +16,7 @@ Or if you using CommonJS
1616
```js
1717
const { faker } = require('@faker-js/faker');
1818

19-
const randomName = faker.name.fullName(); // Rowan Nikolaus
19+
const randomName = faker.person.fullName(); // Rowan Nikolaus
2020
const randomEmail = faker.internet.email(); // [email protected]
2121
```
2222

@@ -27,7 +27,7 @@ const randomEmail = faker.internet.email(); // [email protected]
2727
import { faker } from 'https://cdn.skypack.dev/@faker-js/faker';
2828
2929
// Caitlyn Kerluke
30-
const randomName = faker.name.fullName();
30+
const randomName = faker.person.fullName();
3131
3232
3333
const randomEmail = faker.internet.email();
@@ -43,7 +43,7 @@ Using the browser is great for experimenting 👍. However, due to all of the st
4343
```js
4444
import { faker } from 'https://cdn.skypack.dev/@faker-js/faker';
4545

46-
const randomName = faker.name.findName(); // Willie Bahringer
46+
const randomName = faker.person.findName(); // Willie Bahringer
4747
const randomEmail = faker.internet.email(); // [email protected]
4848
```
4949

@@ -120,9 +120,9 @@ function createRandomUser(): User {
120120
avatar: faker.image.avatar(),
121121
birthday: faker.date.birthdate(),
122122
email: faker.internet.email(),
123-
firstName: faker.name.firstName(),
124-
lastName: faker.name.lastName(),
125-
sex: faker.name.sexType(),
123+
firstName: faker.person.firstName(),
124+
lastName: faker.person.lastName(),
125+
sex: faker.person.sexType(),
126126
subscriptionTier: faker.helpers.arrayElement(['free', 'basic', 'business']),
127127
};
128128
}
@@ -142,9 +142,9 @@ Let's refactor our current code:
142142
import { faker } from '@faker-js/faker';
143143

144144
function createRandomUser(): User {
145-
const sex = this.faker.name.sexType();
146-
const firstName = faker.name.firstName(sex);
147-
const lastName = faker.name.lastName();
145+
const sex = this.faker.person.sexType();
146+
const firstName = faker.person.firstName(sex);
147+
const lastName = faker.person.lastName();
148148
const email = faker.internet.email(firstName, lastName);
149149

150150
return {
@@ -179,9 +179,9 @@ Faker has your back, with another helper method:
179179
import { faker } from '@faker-js/faker';
180180

181181
function createRandomUser(): User {
182-
const sex = this.faker.name.sexType();
183-
const firstName = faker.name.firstName(sex);
184-
const lastName = faker.name.lastName();
182+
const sex = this.faker.person.sexType();
183+
const firstName = faker.person.firstName(sex);
184+
const lastName = faker.person.lastName();
185185
const email = faker.helpers.unique(faker.internet.email, [
186186
firstName,
187187
lastName,

scripts/apidoc/moduleMethods.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ export function processModuleMethods(project: ProjectReflection): PageIndex {
3838
}
3939

4040
export function extractModuleName(module: DeclarationReflection): string {
41-
return module.name.replace(/Module$/, '');
41+
const { name } = module;
42+
// TODO @ST-DDT 2022-10-16: Remove in v10.
43+
// Typedoc prefers the name of the module that is exported first.
44+
if (name === 'NameModule') {
45+
return 'Person';
46+
}
47+
return name.replace(/Module$/, '');
4248
}
4349

4450
function extractModuleFieldName(module: DeclarationReflection): string {

scripts/generateLocales.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const definitionsTypes: DefinitionsType = {
5757
internet: 'InternetDefinitions',
5858
lorem: 'LoremDefinitions',
5959
music: 'MusicDefinitions',
60-
name: 'NameDefinitions',
60+
person: 'PersonDefinitions',
6161
phone_number: 'PhoneNumberDefinitions',
6262
science: 'ScienceDefinitions',
6363
system: 'SystemDefinitions',

src/definitions/definitions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { HackerDefinitions } from './hacker';
1010
import type { InternetDefinitions } from './internet';
1111
import type { LoremDefinitions } from './lorem';
1212
import type { MusicDefinitions } from './music';
13-
import type { NameDefinitions } from './name';
13+
import type { PersonDefinitions } from './person';
1414
import type { PhoneNumberDefinitions } from './phone_number';
1515
import type { ScienceDefinitions } from './science';
1616
import type { SystemDefinitions } from './system';
@@ -38,7 +38,7 @@ export interface Definitions {
3838
internet: InternetDefinitions;
3939
lorem: LoremDefinitions;
4040
music: MusicDefinitions;
41-
name: NameDefinitions;
41+
person: PersonDefinitions;
4242
phone_number: PhoneNumberDefinitions;
4343
science: ScienceDefinitions;
4444
system: SystemDefinitions;

src/definitions/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export type { HackerDefinitions } from './hacker';
1717
export type { InternetDefinitions } from './internet';
1818
export type { LoremDefinitions } from './lorem';
1919
export type { MusicDefinitions } from './music';
20-
export type { NameDefinitions, NameTitleDefinitions } from './name';
20+
export type { PersonDefinitions, PersonTitleDefinitions } from './person';
2121
export type { PhoneNumberDefinitions } from './phone_number';
2222
export type { ScienceDefinitions } from './science';
2323
export type {

src/definitions/name.ts renamed to src/definitions/person.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { LocaleEntry } from './definitions';
33
/**
44
* The possible definitions related to people's names.
55
*/
6-
export type NameDefinitions = LocaleEntry<{
6+
export type PersonDefinitions = LocaleEntry<{
77
gender: string[];
88
sex: string[];
99

@@ -30,13 +30,13 @@ export type NameDefinitions = LocaleEntry<{
3030
*/
3131
name: string[];
3232

33-
title: NameTitleDefinitions;
33+
title: PersonTitleDefinitions;
3434
}>;
3535

3636
/**
3737
* The possible definitions related to people's titles.
3838
*/
39-
export interface NameTitleDefinitions {
39+
export interface PersonTitleDefinitions {
4040
descriptor?: string[];
4141
job: string[];
4242
level?: string[];

src/faker.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { LocaleDefinition } from './definitions';
22
import { FakerError } from './errors/faker-error';
3+
import { deprecated } from './internal/deprecated';
34
import type { Mersenne } from './internal/mersenne/mersenne';
45
import mersenne from './internal/mersenne/mersenne';
56
import type { KnownLocale } from './locales';
@@ -19,7 +20,8 @@ import { ImageModule } from './modules/image';
1920
import { InternetModule } from './modules/internet';
2021
import { LoremModule } from './modules/lorem';
2122
import { MusicModule } from './modules/music';
22-
import { NameModule } from './modules/name';
23+
import type { PersonModule as NameModule } from './modules/person';
24+
import { PersonModule } from './modules/person';
2325
import { PhoneModule } from './modules/phone';
2426
import { RandomModule } from './modules/random';
2527
import { ScienceModule } from './modules/science';
@@ -98,13 +100,25 @@ export class Faker {
98100
readonly internet: InternetModule = new InternetModule(this);
99101
readonly lorem: LoremModule = new LoremModule(this);
100102
readonly music: MusicModule = new MusicModule(this);
101-
readonly name: NameModule = new NameModule(this);
103+
readonly person: PersonModule = new PersonModule(this);
102104
readonly phone: PhoneModule = new PhoneModule(this);
103105
readonly science: ScienceModule = new ScienceModule(this);
104106
readonly system: SystemModule = new SystemModule(this);
105107
readonly vehicle: VehicleModule = new VehicleModule(this);
106108
readonly word: WordModule = new WordModule(this);
107109

110+
// Aliases
111+
/** @deprecated Use {@link person} instead */
112+
get name(): NameModule {
113+
deprecated({
114+
deprecated: 'faker.name',
115+
proposed: 'faker.person',
116+
since: '8.0.0',
117+
until: '10.0.0',
118+
});
119+
return this.person;
120+
}
121+
108122
constructor(opts: FakerOptions) {
109123
if (!opts) {
110124
throw new FakerError(
@@ -159,6 +173,17 @@ export class Faker {
159173

160174
return new Proxy({} as LocaleDefinition, {
161175
get(target: LocaleDefinition, module: string): unknown {
176+
// Support aliases
177+
if (module === 'name') {
178+
module = 'person';
179+
deprecated({
180+
deprecated: `faker.helpers.fake('{{name.*}}') or faker.definitions.name`,
181+
proposed: `faker.helpers.fake('{{person.*}}') or faker.definitions.person`,
182+
since: '8.0.0',
183+
until: '10.0.0',
184+
});
185+
}
186+
162187
let result = target[module];
163188
if (result) {
164189
return result;

src/index.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ export type {
1818
LocaleDefinition,
1919
LoremDefinitions,
2020
MusicDefinitions,
21-
NameDefinitions,
22-
NameTitleDefinitions,
21+
/** @deprecated Use PersonDefinitions instead */
22+
PersonDefinitions as NameDefinitions,
23+
PersonDefinitions,
24+
/** @deprecated Use PersonTitleDefinitions instead */
25+
PersonTitleDefinitions as NameTitleDefinitions,
26+
PersonTitleDefinitions,
2327
PhoneNumberDefinitions,
2428
ScienceDefinitions,
2529
SystemDefinitions,
@@ -53,8 +57,13 @@ export type { ImageModule } from './modules/image';
5357
export type { InternetModule } from './modules/internet';
5458
export type { LoremModule } from './modules/lorem';
5559
export type { MusicModule } from './modules/music';
56-
export { Sex } from './modules/name';
57-
export type { NameModule, SexType } from './modules/name';
60+
export { Sex } from './modules/person';
61+
export type {
62+
/** @deprecated Use PersonModule instead */
63+
PersonModule as NameModule,
64+
PersonModule,
65+
SexType,
66+
} from './modules/person';
5867
export type { PhoneModule } from './modules/phone';
5968
export type { RandomModule } from './modules/random';
6069
export type { ChemicalElement, ScienceModule, Unit } from './modules/science';

src/locales/af_ZA/address/city.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export default [
2-
'{{address.city_prefix}} {{name.firstName}}{{address.city_suffix}}',
3-
'{{address.city_prefix}} {{name.firstName}}',
4-
'{{name.firstName}}{{address.city_suffix}}',
5-
'{{name.lastName}}{{address.city_suffix}}',
2+
'{{address.city_prefix}} {{person.firstName}}{{address.city_suffix}}',
3+
'{{address.city_prefix}} {{person.firstName}}',
4+
'{{person.firstName}}{{address.city_suffix}}',
5+
'{{person.lastName}}{{address.city_suffix}}',
66
];

src/locales/af_ZA/address/street.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export default [
2-
'{{name.firstName}} {{address.street_suffix}}',
3-
'{{name.lastName}} {{address.street_suffix}}',
2+
'{{person.firstName}} {{address.street_suffix}}',
3+
'{{person.lastName}} {{address.street_suffix}}',
44
];

src/locales/af_ZA/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import address from './address';
77
import cell_phone from './cell_phone';
88
import company from './company';
99
import internet from './internet';
10-
import name_ from './name';
10+
import person from './person';
1111
import phone_number from './phone_number';
1212

1313
const af_ZA: LocaleDefinition = {
@@ -16,7 +16,7 @@ const af_ZA: LocaleDefinition = {
1616
cell_phone,
1717
company,
1818
internet,
19-
name: name_,
19+
person,
2020
phone_number,
2121
};
2222

src/locales/zu_ZA/name/index.ts renamed to src/locales/af_ZA/person/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
* This file is automatically generated.
33
* Run 'pnpm run generate:locales' to update.
44
*/
5-
import type { NameDefinitions } from '../../..';
5+
import type { PersonDefinitions } from '../../..';
66
import female_first_name from './female_first_name';
77
import first_name from './first_name';
88
import last_name from './last_name';
99
import male_first_name from './male_first_name';
1010

11-
const name: NameDefinitions = {
11+
const person: PersonDefinitions = {
1212
female_first_name,
1313
first_name,
1414
last_name,
1515
male_first_name,
1616
};
1717

18-
export default name;
18+
export default person;

src/locales/ar/address/street.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export default [
2-
'{{address.street_prefix}} {{name.first_name}}',
3-
'{{address.street_prefix}} {{name.last_name}}',
2+
'{{address.street_prefix}} {{person.first_name}}',
3+
'{{address.street_prefix}} {{person.last_name}}',
44
];

src/locales/ar/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import cell_phone from './cell_phone';
88
import color from './color';
99
import commerce from './commerce';
1010
import date from './date';
11-
import name_ from './name';
11+
import person from './person';
1212
import phone_number from './phone_number';
1313
import team from './team';
1414
import vehicle from './vehicle';
@@ -21,7 +21,7 @@ const ar: LocaleDefinition = {
2121
color,
2222
commerce,
2323
date,
24-
name: name_,
24+
person,
2525
phone_number,
2626
team,
2727
vehicle,

src/locales/ar/name/name.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/locales/hr/name/index.ts renamed to src/locales/ar/person/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* This file is automatically generated.
33
* Run 'pnpm run generate:locales' to update.
44
*/
5-
import type { NameDefinitions } from '../../..';
5+
import type { PersonDefinitions } from '../../..';
66
import female_first_name from './female_first_name';
77
import first_name from './first_name';
88
import last_name from './last_name';
@@ -12,7 +12,7 @@ import prefix from './prefix';
1212
import suffix from './suffix';
1313
import title from './title';
1414

15-
const name: NameDefinitions = {
15+
const person: PersonDefinitions = {
1616
female_first_name,
1717
first_name,
1818
last_name,
@@ -23,4 +23,4 @@ const name: NameDefinitions = {
2323
title,
2424
};
2525

26-
export default name;
26+
export default person;
File renamed without changes.

src/locales/ar/person/name.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default [
2+
'{{person.prefix}} {{person.first_name}} {{person.last_name}}',
3+
'{{person.first_name}} {{person.last_name}}',
4+
'{{person.last_name}} {{person.first_name}}',
5+
];
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/locales/az/company/name_patterns.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default [
2-
'{{company.prefix}} {{name.female_first_name}}',
3-
'{{company.prefix}} {{name.male_first_name}}',
4-
'{{company.prefix}} {{name.male_last_name}}',
2+
'{{company.prefix}} {{person.female_first_name}}',
3+
'{{company.prefix}} {{person.male_first_name}}',
4+
'{{company.prefix}} {{person.male_last_name}}',
55
'{{company.prefix}} {{company.suffix}}{{company.suffix}}',
66
'{{company.prefix}} {{company.suffix}}{{company.suffix}}{{company.suffix}}',
77
'{{company.prefix}} {{address.city_name}}{{company.suffix}}',

0 commit comments

Comments
 (0)