Skip to content

Commit acff2a1

Browse files
authored
Merge branch 'next' into docs/api/default/prevent-line-breaks
2 parents d3fe89b + d5e697d commit acff2a1

File tree

151 files changed

+1601
-10899
lines changed

Some content is hidden

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

151 files changed

+1601
-10899
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// README at: https://github.com/devcontainers/templates/tree/main/src/typescript-node
33
{
44
"name": "FakerJs",
5-
"image": "mcr.microsoft.com/devcontainers/typescript-node:22@sha256:79c4181532784148abe5d0dd37505f420674990fd104f8294fd06155003fa442",
5+
"image": "mcr.microsoft.com/devcontainers/typescript-node:22@sha256:dc2c3654370fe92a55daeefe9d2d95839d85bdc1f68f7fd4ab86621f49e5818a",
66

77
// Features to add to the dev container. More info: https://containers.dev/features.
88
// "features": {},

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ For detailed API documentation, please select the version of the documentation y
3434

3535
## 🚀 Features
3636

37-
- 💌 Locations - Generate valid looking Addresses, Zip Codes, Street Names, States, and Countries!
38-
- ⏰ Time-based Data - Past, present, future, recent, soon... whenever!
39-
- 🌏 Localization - Pick a locale to generate realistic looking Names, Addresses, and Phone Numbers.
37+
- 🧍 Person - Generate Names, Genders, Bios, Job titles, and more.
38+
- 📍 Location - Generate Addresses, Zip Codes, Street Names, States, and Countries!
39+
- ⏰ Date - Past, present, future, recent, soon... whenever!
4040
- 💸 Finance - Create stubbed out Account Details, Transactions, and Crypto Addresses.
41-
- 👠 Products - Generate Prices, Product Names, Adjectives, and Descriptions.
42-
- 👾 Hacker Jargon - “Try to reboot the SQL bus, maybe it will bypass the virtual application!”
43-
- 🧍 Names - Generate virtual humans with a complete online and offline identity.
44-
- 🔢 Numbers - Of course, we can also generate random numbers and strings.
41+
- 👠 Commerce - Generate Prices, Product Names, Adjectives, and Descriptions.
42+
- 👾 Hacker - “Try to reboot the SQL bus, maybe it will bypass the virtual application!”
43+
- 🔢 Number and String - Of course, we can also generate random numbers and strings.
44+
- 🌏 Localization - Pick from over 60 locales to generate realistic looking Names, Addresses, and Phone Numbers.
4545

4646
> **Note**: Faker tries to generate realistic data and not obvious fake data.
4747
> The generated names, addresses, emails, phone numbers, and/or other data might be coincidentally valid information.

docs/guide/usage.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,4 +260,49 @@ This allows the value to be more reasonable based on the provided arguments.
260260

261261
Unlike the `_id` property that uses an `uuid` implementation, which has a low chance of duplicates, the `email` function is more likely to produce duplicates, especially if the call arguments are similar. We have a dedicated guide page on generating [unique values](unique).
262262

263-
Congratulations, you should now be able to create any complex object you desire. Happy faking 🥳.
263+
The example above demonstrates how to generate complex objects.
264+
To gain more control over the values of specific properties, you can introduce `overwrites`, `options` or similar parameters:
265+
266+
```ts {3,17}
267+
import { faker } from '@faker-js/faker';
268+
269+
function createRandomUser(overwrites: Partial<User> = {}): User {
270+
const {
271+
_id = faker.string.uuid(),
272+
avatar = faker.image.avatar(),
273+
birthday = faker.date.birthdate(),
274+
sex = faker.person.sexType(),
275+
firstName = faker.person.firstName(sex),
276+
lastName = faker.person.lastName(),
277+
email = faker.internet.email({ firstName, lastName }),
278+
subscriptionTier = faker.helpers.arrayElement([
279+
'free',
280+
'basic',
281+
'business',
282+
]),
283+
} = overwrites;
284+
285+
return {
286+
_id,
287+
avatar,
288+
birthday,
289+
email,
290+
firstName,
291+
lastName,
292+
sex,
293+
subscriptionTier,
294+
};
295+
}
296+
297+
const user = createRandomUser();
298+
const userToReject = createRandomUser({ birthday: new Date('2124-10-20') });
299+
```
300+
301+
A potential `options` parameter could be used to:
302+
303+
- control which optional properties are included,
304+
- control how nested elements and arrays are merged or replaced,
305+
- or specify the number of items to generate for nested lists.
306+
307+
Congratulations, you should now be able to create any complex object you desire.
308+
Happy faking 🥳.

docs/index.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,24 @@ hero:
2020
link: https://github.com/faker-js/faker
2121

2222
features:
23-
- icon: 👠
24-
title: Products
25-
details: Generate Prices, Product Names, Adjectives, and Descriptions.
23+
- icon: 🧍
24+
title: Person
25+
details: Generate Names, Genders, Bios, Job titles, and more.
26+
- icon: 📍
27+
title: Location
28+
details: Generate Addresses, Zip Codes, Street Names, States, and Countries!
29+
- icon:
30+
title: Date
31+
details: Past, present, future, recent, soon... whenever!
2632
- icon: 💸
2733
title: Finance
2834
details: Create stubbed out Account Details, Transactions, and Crypto Addresses.
29-
- icon: 💌
30-
title: Locations
31-
details: Generate valid Addresses, Zip Codes, Street Names, States, and Countries!
32-
- icon: 👾
33-
title: Hacker Jargon
34-
details: “Try to reboot the SQL bus, maybe it will bypass the virtual application!”
35-
- icon:
36-
title: Time-based Data
37-
details: Past, present, future, recent, soon... whenever!
35+
- icon: 👠
36+
title: Commerce
37+
details: Generate Prices, Product Names, Adjectives, and Descriptions.
3838
- icon: 🌏
3939
title: Localization
40-
details: Pick a locale to generate realistic looking Names, Addresses, and Phone Numbers.
40+
details: Pick from over 60 locales to generate realistic looking Names, Addresses, and Phone Numbers.
4141
---
4242

4343
<div class="opencollective">

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
"eslint-plugin-jsdoc": "50.4.3",
124124
"eslint-plugin-prettier": "5.2.1",
125125
"eslint-plugin-unicorn": "56.0.0",
126-
"jiti": "1.21.6",
126+
"jiti": "2.3.3",
127127
"npm-run-all2": "6.2.3",
128128
"prettier": "3.3.3",
129129
"prettier-plugin-organize-imports": "4.1.0",
@@ -143,7 +143,7 @@
143143
"vue": "3.5.12",
144144
"vue-tsc": "2.1.6"
145145
},
146-
"packageManager": "[email protected].1",
146+
"packageManager": "[email protected].2",
147147
"engines": {
148148
"node": ">=18.0.0",
149149
"npm": ">=9.0.0"

0 commit comments

Comments
 (0)