diff options
| author | Shinigami <[email protected]> | 2023-05-08 10:36:43 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-05-08 08:36:43 +0000 |
| commit | 30b40ada8f9ed8195a7c088c5057d5a9748df897 (patch) | |
| tree | f100b4c775a53bf346fc63954e4568a51fdc5c3b /docs | |
| parent | 23eb0f5b3962f334dbbf8fda52b6639ff7b66a96 (diff) | |
| download | faker-30b40ada8f9ed8195a7c088c5057d5a9748df897.tar.xz faker-30b40ada8f9ed8195a7c088c5057d5a9748df897.zip | |
docs: minor enhancements (#2131)
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/guide/index.md | 16 | ||||
| -rw-r--r-- | docs/guide/localization.md | 4 | ||||
| -rw-r--r-- | docs/guide/usage.md | 19 |
3 files changed, 23 insertions, 16 deletions
diff --git a/docs/guide/index.md b/docs/guide/index.md index cfee521d..58a9b974 100644 --- a/docs/guide/index.md +++ b/docs/guide/index.md @@ -21,21 +21,21 @@ You can run Faker in the Browser, within Node, or the many other languages suppo Install it as a Dev Dependency using your favorite package manager. -```shell +::: code-group + +```shell [npm] npm install @faker-js/faker --save-dev ``` -or +```shell [pnpm] +pnpm add @faker-js/faker --save-dev +``` -```shell +```shell [yarn] yarn add @faker-js/faker --dev ``` -or - -```shell -pnpm add @faker-js/faker --save-dev -``` +::: ## Community diff --git a/docs/guide/localization.md b/docs/guide/localization.md index 446c914a..af91383b 100644 --- a/docs/guide/localization.md +++ b/docs/guide/localization.md @@ -28,7 +28,7 @@ import { faker } from '@faker-js/faker/locale/de'; This will then just load the German locales with additional English locales as fallback. The fallback is required due to not all locales containing data for all features. If you encounter a missing locale entry in your selected language, feel free to open a Pull Request fixing that issue. -::: info +::: info Info The English locales are around 600 KB in size. All locales together are around 5 MB in size. ::: @@ -159,6 +159,7 @@ The recommended way to access Faker instances is by using one of the individual ```ts import { allFakers, allLocales } from '@faker-js/faker'; + console.dir(allFakers['de_AT']); // the prebuilt Faker instance for de_AT console.dir(allLocales['de_AT']); // the raw locale definitions for de_AT ``` @@ -167,6 +168,7 @@ This could be useful if you want to enumerate all locales, for example: ```ts import { allFakers } from '@faker-js/faker'; + for (let key of Object.keys(allFakers)) { try { console.log( diff --git a/docs/guide/usage.md b/docs/guide/usage.md index 767cf747..452e415c 100644 --- a/docs/guide/usage.md +++ b/docs/guide/usage.md @@ -4,23 +4,28 @@ Using Faker is as easy as importing it from `@faker-js/faker`. -```js +::: code-group + +```js [esm] import { faker } from '@faker-js/faker'; // or, if desiring a different locale -// import { fakerDE as faker } from '@faker-js/faker' +// import { fakerDE as faker } from '@faker-js/faker'; + const randomName = faker.person.fullName(); // Rowan Nikolaus const randomEmail = faker.internet.email(); // [email protected] ``` -Or if you're using CommonJS: - -```js +```js [cjs] const { faker } = require('@faker-js/faker'); +// or, if desiring a different locale +// const { fakerDE: faker } = require('@faker-js/faker'); const randomName = faker.person.fullName(); // Rowan Nikolaus const randomEmail = faker.internet.email(); // [email protected] ``` +::: + For more information about changing and customizing the locales, please refer to our [Localization Guide](localization). ## Browser @@ -119,7 +124,7 @@ or alternatively you can set a default reference date for all these methods: ```ts // affects all future faker.date.* calls -faker.defaultRefDate = '2023-01-01T00:00:00.000Z'; +faker.setDefaultRefDate('2023-01-01T00:00:00.000Z'); ``` ## Create complex objects @@ -220,7 +225,7 @@ But, in most use-cases, this would be desirable. Faker has your back, with another helper method: -```ts {7-9} +```ts {7-10} import { faker } from '@faker-js/faker'; function createRandomUser(): User { |
