Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Eric Cheng <[email protected]>
  • Loading branch information
Shinigami92 and ejcheng authored Feb 23, 2024
1 parent 3088b39 commit 2fc6591
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/guide/unique.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ faker.animal.type(); //'horse'
faker.animal.type(); //'horse'
```

Some methods and locales use a much smaller data sets than others. For example `faker.animal.type` has only 13 possible animals to choose from. By contrast `faker.person.fullName()` pulls from a list of hundreds of first names, surnames and prefixes/suffixes, so it can generate hundreds of thousands of unique names. Even then, the [birthday paradox](https://en.wikipedia.org/wiki/Birthday_Paradox) means that duplicate values will quickly be generated.
Some methods and locales use much smaller data sets than others. For example, `faker.animal.type` has only 13 possible animals to choose from. In contrast, `faker.person.fullName()` pulls from a list of hundreds of first names, surnames, and prefixes/suffixes, so it can generate hundreds of thousands of unique names. Even then, the [birthday paradox](https://en.wikipedia.org/wiki/Birthday_Paradox) means that duplicate values will quickly be generated.

Sometimes you want to generate unique values, for example you may wish to have unique values in a database email column.
Sometimes, you want to generate unique values. For example, you may wish to have unique values in a database email column.
There are a few possible strategies for this:

1. Use `faker.helpers.uniqueArray()` if you want to generate all the values at one time. For example
1. Use `faker.helpers.uniqueArray()` if you want to generate all the values at one time. For example:

```ts
faker.helpers.uniqueArray(faker.internet.email, 1000); // will generate 1000 unique email addresses
Expand Down

0 comments on commit 2fc6591

Please sign in to comment.