From 71e902599651b645cdb6996c8cd562e8007a32ea Mon Sep 17 00:00:00 2001 From: Jess Date: Wed, 12 Jan 2022 19:48:48 -0500 Subject: feat: adding documentation with vitepress (#80) --- docs/.vitepress/config.mjs | 114 +++++++++ docs/.vitepress/theme/components/Badge.vue | 43 ++++ docs/.vitepress/theme/components/Playground.vue | 18 ++ docs/.vitepress/theme/components/index.mjs | 7 + docs/.vitepress/theme/index.mjs | 11 + docs/api/address.md | 181 ++++++++++++++ docs/api/commerce.md | 62 +++++ docs/api/company.md | 106 ++++++++ docs/api/database.md | 35 +++ docs/api/datatype.md | 125 ++++++++++ docs/api/date.md | 129 ++++++++++ docs/api/fake.md | 11 + docs/api/finance.md | 167 +++++++++++++ docs/api/hacker.md | 51 ++++ docs/api/helpers.md | 262 +++++++++++++++++++ docs/api/image.md | 318 ++++++++++++++++++++++++ docs/api/internet.md | 186 ++++++++++++++ docs/api/localization.md | 67 +++++ docs/guide/index.md | 64 +++++ docs/guide/recent-faqs.md | 52 ++++ docs/index.md | 24 ++ docs/playground/index.md | 5 + docs/public/logo.svg | 4 + 23 files changed, 2042 insertions(+) create mode 100644 docs/.vitepress/config.mjs create mode 100644 docs/.vitepress/theme/components/Badge.vue create mode 100644 docs/.vitepress/theme/components/Playground.vue create mode 100644 docs/.vitepress/theme/components/index.mjs create mode 100644 docs/.vitepress/theme/index.mjs create mode 100644 docs/api/address.md create mode 100644 docs/api/commerce.md create mode 100644 docs/api/company.md create mode 100644 docs/api/database.md create mode 100644 docs/api/datatype.md create mode 100644 docs/api/date.md create mode 100644 docs/api/fake.md create mode 100644 docs/api/finance.md create mode 100644 docs/api/hacker.md create mode 100644 docs/api/helpers.md create mode 100644 docs/api/image.md create mode 100644 docs/api/internet.md create mode 100644 docs/api/localization.md create mode 100644 docs/guide/index.md create mode 100644 docs/guide/recent-faqs.md create mode 100644 docs/index.md create mode 100644 docs/playground/index.md create mode 100644 docs/public/logo.svg (limited to 'docs') diff --git a/docs/.vitepress/config.mjs b/docs/.vitepress/config.mjs new file mode 100644 index 00000000..5341a114 --- /dev/null +++ b/docs/.vitepress/config.mjs @@ -0,0 +1,114 @@ +import { defineConfig } from 'vitepress'; + +const nav = [ + { text: 'Guide', link: '/guide/' }, + // { text: 'Playground', link: '/playground/' }, +]; + +const sidebar = { + '/': [ + { + text: 'Guide', + children: [ + { + text: 'Recent Statement and FAQs', + link: '/guide/recent-faqs', + }, + { + text: 'Getting Started', + link: '/guide/', + }, + ], + }, + { + text: 'API', + children: [ + { + text: 'Address', + link: '/api/address', + collapsable: false, // optional, defaults to true + }, + { + text: 'Commerce', + link: '/api/commerce', + }, + { + text: 'Company', + link: '/api/company', + }, + { + text: 'Database', + link: '/api/database', + }, + { + text: 'Datatype', + link: '/api/datatype', + }, + { + text: 'Date', + link: '/api/date', + }, + { + text: 'Fake', + link: '/api/fake', + }, + { + text: 'Finance', + link: '/api/finance', + }, + { + text: 'Hacker', + link: '/api/hacker', + }, + { + text: 'Helpers', + link: '/api/helpers', + }, + { + text: 'Image', + link: '/api/image', + }, + { + text: 'Internet', + link: '/api/internet', + }, + { + text: 'Localization', + link: '/api/localization', + }, + ], + }, + ], +}; + +// grab from process.env once this is building on netlify +const algolia = { + apiKey: '', + indexName: '', + searchParameters: { + facetFilters: [''], + }, +}; + +export default defineConfig({ + // Empty in order to use the faker.js logo instead of a text title. + // If we had a square logo, we could use it here. + title: 'Faker', + description: + 'Generate massive amounts of fake data in the browser and node.js', + head: [ + ['link', { rel: 'icon', href: '/logo.svg' }], + ['meta', { name: 'theme-color', content: '#40af7c' }], + ], + themeConfig: { + repo: 'faker-js/faker', + logo: '/logo.svg', + docsDir: 'docs', + docsBranch: 'main', + editLinks: true, + editLinkText: 'Suggest changes to this page', + nav, + sidebar, + algolia, + }, +}); diff --git a/docs/.vitepress/theme/components/Badge.vue b/docs/.vitepress/theme/components/Badge.vue new file mode 100644 index 00000000..5ec0673c --- /dev/null +++ b/docs/.vitepress/theme/components/Badge.vue @@ -0,0 +1,43 @@ + + + + + diff --git a/docs/.vitepress/theme/components/Playground.vue b/docs/.vitepress/theme/components/Playground.vue new file mode 100644 index 00000000..d872798b --- /dev/null +++ b/docs/.vitepress/theme/components/Playground.vue @@ -0,0 +1,18 @@ + + + diff --git a/docs/.vitepress/theme/components/index.mjs b/docs/.vitepress/theme/components/index.mjs new file mode 100644 index 00000000..6a1c639d --- /dev/null +++ b/docs/.vitepress/theme/components/index.mjs @@ -0,0 +1,7 @@ +import Playground from './Playground.vue'; +import Badge from './Badge.vue'; + +export default { + Playground, + Badge, +}; diff --git a/docs/.vitepress/theme/index.mjs b/docs/.vitepress/theme/index.mjs new file mode 100644 index 00000000..26a6b5ca --- /dev/null +++ b/docs/.vitepress/theme/index.mjs @@ -0,0 +1,11 @@ +import GlobalComponents from './components'; +import DefaultTheme from 'vitepress/theme'; + +export default { + ...DefaultTheme, + enhanceApp({ app }) { + for (const [name, component] of Object.entries(GlobalComponents)) { + app.component(name, component); + } + }, +}; diff --git a/docs/api/address.md b/docs/api/address.md new file mode 100644 index 00000000..421aad7e --- /dev/null +++ b/docs/api/address.md @@ -0,0 +1,181 @@ +# Address + +[[toc]] + +## City + +::: v-pre +Generates a random localized city name. The format string can contain any method provided by faker wrapped in `{{}}`, e.g. `{{name.firstName}}` in order to build the city name. + +::: tip +If no format string is provided one of the following is randomly used: + +- `{{address.cityPrefix}} {{name.firstName}}{{address.citySuffix}}` +- `{{address.cityPrefix}} {{name.firstName}}` +- `{{name.firstName}}{{address.citySuffix}}` +- `{{name.lastName}}{{address.citySuffix}}` + ::: + +```js +faker.address.city(); // Lake Raoulfort +faker.address.city('{{name.lastName}}{{address.citySuffix}}'); // Powlowski port +``` + +## City Prefix + +Return a random localized city prefix + +```js +faker.address.cityPrefix(); // South +``` + +## City Suffix + +Return a random localized city suffix + +```js +faker.address.citySuffix(); // burgh +``` + +## County + +Returns a random county + +```js +faker.address.county(); // Cambridgeshire +``` + +## Country + +Returns a random country + +```js +faker.address.country(); // Papua New Guinea +``` + +## Country Code + +Returns a random country code + +```js +faker.address.countryCode(); // SN +``` + +## Latitude + +Returns a random latitude. + +::: warning Params Available +| Param | Type | Default | +| ----- | ------ | :-----: | +| max | number | `90` | +| min | number | `-90` | +::: + +```js +faker.address.latitude(); // 78.9197 +faker.address.latitude(70, 10); // 40.1239 +``` + +## Longitude + +Returns a random longitude. + +::: warning Params Available +| Param | Type | Default | +| ----- | ------ | :-----: | +| max | number | `180` | +| min | number | `-180` | +::: + +```js +faker.address.longitude(); // 78.9197 +faker.address.longitude(70, 10); // 40.1239 +``` + +## State + +Returns a random state + +```js +faker.address.state(); // Montana +``` + +## State Abbreviation + +Returns a random state abbreviation + +```js +faker.address.stateAbbr(); // WV +``` + +## Street Name + +Returns a random localized street name + +```js +faker.address.streetName(); // Rowe Coves +``` + +## Street Address + +Returns a random localized street address. Pass in optional object boolean to get a full address. + +::: tip +| Param | Type | Default | +| -------------- | ------- | :-----: | +| useFullAddress | boolean | `false` | +::: + +```js +faker.address.streetAddress(); // 294 White Parkways +faker.address.streetAddress(true); // 294 White Parkways Apt. 506 +``` + +## Street Suffix + +Returns a random localized street suffix. + +```js +faker.address.streetSuffix(); // Garden +``` + +## Street Prefix + +Returns a random localized street prefix. + +```js +faker.address.streetPrefix(); // c +``` + +## Secondary Address + +Returns a random Secondary Address + +```js +faker.address.secondaryAddress(); // Suite 123 +``` + +## Zip Code + +Generates random zip code. If format is not specified, the locale's zip format is used. Use formats that are supported with [replaceSymbols](/api/helpers.html#replacesymbols-format) + +::: tip +| Param | Type | Default | +| ------ | ------ | :---------: | +| format | string | `undefined` | +::: + +```js +faker.address.zipCode(); // 98101-1234 +faker.address.zipCode('#####'); // 98101 +``` + +## Zip Code By State + +Generates random Zip Code from state abbreviation. If state abbreviation is not specified, a random zip code is generated according to the locale's zip format. Only works for locales with `postcode_by_state` definition. If a locale does not have a `postcode_by_state` definition, a random zip code is generated according to the locale's zip format. + +```js +faker.address.zipCodeByState(); // 12302 +faker.address.zipCodeByState('wa'); // 98101 +``` diff --git a/docs/api/commerce.md b/docs/api/commerce.md new file mode 100644 index 00000000..a7809709 --- /dev/null +++ b/docs/api/commerce.md @@ -0,0 +1,62 @@ +# Commerce + +[[toc]] + +## Color + +Return random color name + +```js +faker.commerce.color(); // fuchsia +``` + +## Department + +Return random department name + +```js +faker.commerce.department(); // Grocery +``` + +## Price + +Generates random price + +::: tip +| Param | Type | Default | +| ------ | ------ | :-----: | +| min | number | `1` | +| max | number | `1000` | +| dec | number | `2` | +| symbol | string | `` | +::: + +```js +faker.commerce.price(); // 4.00 +faker.commerce.price(2, 22, 1, '$'); // $7.0 +``` + +## Product + +Return random product + +```js +faker.commerce.product(); // Gloves +faker.commerce.productName(); // Rustic Granite Shirt +``` + +## Product Adjective + +Return random product adjective + +```js +faker.commerce.productAdjective(); // Handmade +``` + +## Product Material + +Return random product material + +```js +faker.commerce.productMaterial(); // Steel +``` diff --git a/docs/api/company.md b/docs/api/company.md new file mode 100644 index 00000000..c2919d6f --- /dev/null +++ b/docs/api/company.md @@ -0,0 +1,106 @@ +# Company + +[[toc]] + +## Company Name + +Return random company name. Using one of the following format options +::: v-pre + +- `{{name.lastName}} {{company.companySuffix}}` +- `{{name.lastName}} - {{name.lastName}}` +- `{{name.lastName}}, {{name.lastName}} and {{name.lastName}}` + ::: + +::: tip +| Param | Type | Default | +| ----------- | ------ | :-----: | +| formatIndex | number | `0-2` | +::: + +```js +faker.company.companyName(); // Zboncak and Sons +faker.company.companyName(0); // Nikolaus Group +faker.company.companyName(1); // Keeling - Lind +faker.company.companyName(2); // Swaniawski, Howe and Leffler +``` + +## Company Suffix + +Return random company suffix + +```js +faker.company.companySuffix(); // and Sons +``` + +## Company Suffixes + +Return **array** of company suffixes + +```js +faker.company.suffixes(); // ["Inc", "and Sons", "LLC", "Group"] +``` + +## Catchphrase + +Return random company catch phrase + +```js +faker.company.catchPhrase(); // Team-oriented context-sensitive conglomeration +``` + +## Catchphrase Adjective + +Return random catch phrase adjective + +```js +faker.company.catchPhraseAdjective(); // Down-sized +``` + +## Catchphrase Descriptor + +Return random catch phrase descriptor + +```js +faker.company.catchPhraseDescriptor(); // bi-directional +``` + +## Catchphrase Noun + +Return random catch phrase noun + +```js +faker.company.catchPhraseNoun(); // complexity +``` + +## Company BS 💩 + +Return random company bs + +```js +faker.company.bs(); // ubiquitous empower e-business +``` + +## BS Adjective + +Return random company bs adjective + +```js +faker.company.bsAdjective(); // granular +``` + +## BS Buzzword + +Return random company bs buzz word + +```js +faker.company.bsBuzz(); // facilitate +``` + +## BS Noun + +Return random company bs noun + +```js +faker.company.bsNoun(); // models +``` diff --git a/docs/api/database.md b/docs/api/database.md new file mode 100644 index 00000000..c9be1533 --- /dev/null +++ b/docs/api/database.md @@ -0,0 +1,35 @@ +# Database + +[[toc]] + +## Column + +Return database column name + +```js +faker.database.column(); // createdAt +``` + +## Type + +Return database column type + +```js +faker.database.type(); // text +``` + +## Collation + +Return database collation + +```js +faker.database.collation(); // cp1250_general_ci +``` + +## Engine + +Return database engine + +```js +faker.database.engine(); // MyISAM +``` diff --git a/docs/api/datatype.md b/docs/api/datatype.md new file mode 100644 index 00000000..35a25716 --- /dev/null +++ b/docs/api/datatype.md @@ -0,0 +1,125 @@ +# Data Type + +[[toc]] + +Generate basic data type, starting from `v5.5.0`. Similar functions from `faker.random` will be deprecated. + +## Number + +Generates random `number` data type. + +::: tip +| Param | Type | Default | +| ------- | ----- | :----------------------------------: | +| options | mixed | `{min: 0, max: 99999, precision: 1}` | + +**NOTE**: passing a number as the param will set the `max` value to that number and use the `min` and `precision` defaults +::: + +```js +faker.datatype.number(); // 3451 +faker.datatype.number(86); // 50 +faker.datatype.number({ min: 10 }); // 45991 +faker.datatype.number({ min: 10, max: 100 }); // 14 +faker.datatype.number({ min: 10, max: 100, precision: 0.25 }); // 44.5 +``` + +## Float + +Generates random `float` data type. + +::: tip +| Param | Type | Default | +| ------- | ----- | :----------------------------------: | +| options | mixed | `{min: 0, max: 99999, precision: 1}` | + +**NOTE 1**: passing a number as the param will set the `max` value to that number and use the `min` and `precision` defaults + +**NOTE 2**: javascript has single data type `number` for all kinds of numbers. Statement `typeof(faker.datatype.number(10)) === typeof(faker.datatype.float(10))` equals `true` +::: + +```js +faker.datatype.float(); // 428 +faker.datatype.float(100); // 23 +faker.datatype.float({ min: 10 }); // 1635 +faker.datatype.float({ min: 10, max: 100 }); // 49 +faker.datatype.float({ min: 10, max: 100, precision: 0.1 }); // 81.8 +``` + +## Array + +Generates array of random number or string. + +::: tip +| Param | Type | Default | +| ----- | ----- | :---------------: | +| length | number | 10 | + +**NOTE**: this method has no fine-grained control to create array of numbers or strings only, or specify criteria for array elements +::: + +```js +faker.datatype.array(); // [13,'hfa&', 41, 8301, '(6$bH', 2354, 'V73!', 'm*he?', 11911, 'gbdX#'] +faker.datatype.array(3); // [47460, 'b&r3#', 9003] +``` + +## UUID + +Generates random UUID + +```js +faker.datatype.uuid(); // 54d13fa1-6d84-4717-8fa2-477a62dac76c +``` + +## Boolean + +Generates random `boolean` data type. + +```js +faker.datatype.boolean(); // true +``` + +## String + +Generates random `string` data type. + +::: tip +| Param | Type | Default | +| ----- | ----- | :---------------: | +| length | number | 10 | +::: + +```js +faker.datatype.string(); // 'Y7=bR1.jpW' +faker.datatype.string(5); // '_9Kss' +``` + +## JSON + +Generates random JSON. It has default length of 7, and no options. + +::: tip +**NOTE**: The generated data type is `string`. To treat it like javascript `object`, use `JSON.parse()` function. +::: + +```js +faker.datatype.json(); // {"foo":61342,"bar":1587,"bike":88807,"a":69894,"b":"A?+(5w)E/Z","name":"U@Y`>Ygls}","prop":35014} (string) +JSON.parse(faker.datatype.json()); // (object) +``` + +## Hexadecimal + +Generates random hex (base-16) number. + +::: tip +| Param | Type | Default | +| ----- | ----- | :---------------: | +| length | number | 1 | +**NOTE**: The generated data type is `string`. To treat it like javascript `number`, use `parseInt()` function. +::: + +```js +faker.datatype.hexaDecimal(); // '0xA' (string) +faker.datatype.hexaDecimal(5); // '0x8D620' (string) +parseInt(faker.datatype.hexaDecimal(2)); // 0xC1 (number) +``` diff --git a/docs/api/date.md b/docs/api/date.md new file mode 100644 index 00000000..359a7744 --- /dev/null +++ b/docs/api/date.md @@ -0,0 +1,129 @@ +# Date + +[[toc]] + +## Past + +Return date sometime in the past. + +::: tip +| Param | Type | Default | +| -------- | ------- | :----------: | +| maxYears | number | `1` | +| refDate | Date | `new Date()` | +::: + +```js +faker.date.past(); +// Sat Oct 20 2018 04:19:38 GMT-0700 (Pacific Daylight Time) + +faker.date.past(100); +// Tue Jul 27 1971 21:08:49 GMT-0700 (Pacific Daylight Time) + +faker.date.past(100, new Date(-3000)); +// Wed Dec 07 1881 05:04:18 GMT-0752 (Pacific Standard Time) +``` + +## Future + +Return date sometime in the future. + +::: tip +| Param | Type | Default | +| ------- | ------- | :----------: | +| years | number | `1` | +| refDate | Date | `new Date()` | +::: + +```js +faker.date.future(); +// Mon Sep 02 2019 21:08:33 GMT-0700 (Pacific Daylight Time) + +faker.date.future(100); +// Fri Nov 23 2068 10:43:15 GMT-0800 (Pacific Standard Time) + +faker.date.future(100, new Date(-3000)); +// Mon Jun 26 2051 01:50:51 GMT-0700 (Pacific Daylight Time) +``` + +## Between + +Return date sometime in the future. + +::: tip +| Param | Type | Default | +| ----- | ---- | :------------------------------------------------: | +| from | Date | | +| to | Date | | +::: + +```js +faker.date.between(new Date(0), new Date(365 * 24 * 3600 * 1000)); +// Mon Oct 19 1970 14:12:01 GMT-0700 (Pacific Daylight Time) +``` + +## Recent + +Returns some date recent date + +::: tip +| Param | Type | Default | +| ------- | ------- | :----------: | +| days | number | `1` | +| refDate | Date | `new Date()` | +::: + +```js +faker.date.recent(); +``` + +## Soon + +Return date sometime soon. + +::: tip +| Param | Type | Default | +| ------- | ------- | :----------: | +| days | number | `1` | +| refDate | Date | `new Date()` | +::: + +```js +faker.date.soon(); +``` + +## Month + +Return random month name + +::: tip +| Param | Type | Default | +| ------ | ------ | :-----------------------------: | +| option | object | `{abbr: false, context: false}` | +::: + +```js +faker.date.month(); +// December + +faker.date.month({ abbr: true }); +// Dec +``` + +## Weekday + +Return random weekday name + +::: tip +| Param | Type | Default | +| ------ | ------ | :-----------------------------: | +| option | object | `{abbr: false, context: false}` | +::: + +```js +faker.date.weekday(); +// Sunday + +faker.date.weekday({ abbr: true }); +// Sun +``` diff --git a/docs/api/fake.md b/docs/api/fake.md new file mode 100644 index 00000000..8fae509a --- /dev/null +++ b/docs/api/fake.md @@ -0,0 +1,11 @@ +# Fake + +Useful generator method `faker.fake()` for combining faker API methods using a mustache string format. + +```js +faker.fake('{{name.lastName}}, {{name.firstName}} {{name.suffix}}'); +// Wintheiser, Shaylee Sr. + +faker.fake('{{company.bs}} is short for {{address.streetName}}'); +// cutting-edge leverage web services is short for Flatley Rue +``` diff --git a/docs/api/finance.md b/docs/api/finance.md new file mode 100644 index 00000000..6035dbcc --- /dev/null +++ b/docs/api/finance.md @@ -0,0 +1,167 @@ +# Finance + +[[toc]] + +## Account + +Return random account number + +::: tip +| Param | Type | Default | +| ------ | ------ | :-----: | +| length | number | `8` | +::: + +```js +faker.finance.account(); // 30764440 +faker.finance.account(12); // 194294967472 +``` + +## Account Name + +Return random account name + +```js +faker.finance.accountName(); // Investment Account +``` + +## Routing Number + +Return random routing number + +```js +faker.finance.routingNumber(); +``` + +## Mask + +Return random mask + +::: tip +| Param | Type | Default | +| -------- | ------- | :-----: | +| length | number | `4` | +| parens | boolean | `false` | +| ellipsis | boolean | `false` | +::: + +```js +faker.finance.mask(); // 8493 +faker.finance.mask(5, true); // (17126) +faker.finance.mask(5, true, true); // (...17126) +faker.finance.mask(5, false, true); // ...17126 +``` + +## Amount + +Return random amount + +::: tip +| Param | Type | Default | +| ------ | ------ | :-----: | +| min | number | `0` | +| max | number | `1000` | +| dec | number | `2` | +| symbol | string | `''` | +::: + +```js +faker.finance.amount(); // 466.98 +faker.finance.amount(42); // 197.40 +faker.finance.amount(42, 43); // 42.24 +faker.finance.amount(42, 43, 10); // 42.1601538648 +faker.finance.amount(42, 43, 2, '$'); // $42.89 +``` + +## Transaction Type + +Return random transaction type + +```js +faker.finance.transactionType(); // withdrawal +``` + +## Currency Code + +Return random currency code + +```js +faker.finance.currencyCode(); // HTG USD +``` + +## Currency Name + +Return random currency name + +```js +faker.finance.currencyName(); // Hryvnia +``` + +## Currency Symbol + +Return random currency symbol + +```js +faker.finance.currencySymbol(); // £ +``` + +## Credit Card Number + +Return random credit card number + +::: tip +| Param | Type | Default | +| -------- | ------ | :-----: | +| provider | string | `''` | +::: + +```js +faker.finance.creditCardNumber(); +``` + +## Credit Card CVV + +Return random credit card CVV + +```js +faker.finance.creditCardCVV(); +``` + +## Bitcoin Address + +Return random bitcoin address + +```js +faker.finance.bitcoinAddress(); // 3FINQD7C6JW7XPF4NMNHOJYAXLKLP +``` + +## Ethereum Address + +Return random Ethereum address + +```js +faker.finance.ethereumAddress(); +``` + +## IBAN (Intl. Bank Account Number) + +Return random IBAN (International Bank Account Number) + +::: tip +| Param | Type | Default | +| -------- | ------- | :-----: | +| formated | boolean | `false` | +::: + +```js +faker.finance.iban(); // BE56302102061244 +faker.finance.iban(true); // GI29 MRCH LR1V 0284 KE24 6K8 +``` + +## BIC (Banking Identifier Code) + +Return random BIC (Bank Identifier Code) + +```js +faker.finance.bic(); // OUAIDGK1 +``` diff --git a/docs/api/hacker.md b/docs/api/hacker.md new file mode 100644 index 00000000..d692d4ae --- /dev/null +++ b/docs/api/hacker.md @@ -0,0 +1,51 @@ +# Hacker + +[[toc]] + +## Abbreviation + +Return random abbreviation + +```js +faker.hacker.abbreviation(); // SMTP +``` + +## Adjective + +Return random adjective + +```js +faker.hacker.adjective(); // wireless +``` + +## Noun + +Return random noun + +```js +faker.hacker.noun(); // capacitor +``` + +## Phrase + +Return random phrase + +```js +faker.hacker.phrase(); // Try to reboot the SQL bus, maybe it will bypass the virtual application! +``` + +## Verb + +Return random verb + +```js +faker.hacker.verb(); // parse +``` + +## -ing Verb + +Return random ingverb + +```js +faker.hacker.ingverb(); // programming +``` diff --git a/docs/api/helpers.md b/docs/api/helpers.md new file mode 100644 index 00000000..7a2db0d2 --- /dev/null +++ b/docs/api/helpers.md @@ -0,0 +1,262 @@ +# Helpers + +[[toc]] + +## Randomize Array + +Returns a random value from the provided array + +::: tip +| Param | Type | Default | +| ----- | ----- | :---------------: | +| array | array | `["a", "b", "c"]` | +::: + +```js +faker.helpers.randomize(); // a +faker.helpers.randomize(['bob', 'joe', 'tim']); // joe +``` + +## Slugify + +slugify the provided string + +::: tip +| Param | Type | Default | +| ------ | ------ | :-----: | +| string | string | `""` | +::: + +```js +faker.helpers.slugify(); // "" +faker.helpers.slugify('bob was here'); // bob-was-here +``` + +## Replace Symbol From Number + +Replace a symbol with a number + +::: tip +| Param | Type | Default | +| ------ | ------ | :-----: | +| string | string | `""` | +| symbol | string | `"#"` | +::: + +```js +faker.helpers.replaceSymbolWithNumber(); // "" +faker.helpers.replaceSymbolWithNumber('bob###@example.com'); // bob790@example.com +faker.helpers.replaceSymbolWithNumber('bob????##???', '?'); // bob6269##849 +``` + +## Replace Symbols + +Parses string for symbols (numbers or letters) and replaces them appropriately. + +- `#` will be replaced with a number, +- `?` with be replaced with a letter +- `*` will be replaced with a number or a letter + +::: tip +| Param | Type | Default | +| ------ | ------ | :-----: | +| format | string | `""` | +::: + +```js +faker.helpers.replaceSymbols('#####'); // 98101 +faker.helpers.replaceSymbols('???'); // ABC +faker.helpers.replaceSymbols('bob-###-42-??'); // bob-226-42-KB +``` + +## Shuffle Array + +Takes an array and returns it randomized + +::: tip +| Param | Type | Default | +| ----- | ----- | :-----: | +| array | array | `[]` | +::: + +```js +faker.helpers.shuffle(); // [] +faker.helpers.shuffle(['a', 'b', 'c']); // ["c", "a", "b"] +``` + +## Mustache + +replaces mustache variable in string with provided key pair + +::: tip +| Param | Type | Default | +| ----- | ------ | :-----: | +| str | string | `n/a` | +| data | object | `n/a` | +::: + +```js +faker.helpers.mustache(); // "" +faker.helpers.mustache('{{foo}} was {{baz}}', { foo: 'bar', baz: 42 }); // bar was 42 +``` + +## Create Card + +Returns an object, but the data is not consistent within itself. Please use [Contextual Card](/api/helpers.html#contextual-card) for data that is self-consistent. + +```js +faker.helpers.createCard(); +``` + +```json +{ + "name": "Glen Hahn", + "username": "Darrin_Champlin84", + "email": "Benton_Swift30@hotmail.com", + "address": { + "streetA": "Dickinson Forest", + "streetB": "63914 Eldora Forge", + "streetC": "095 Bella Lodge Apt. 590", + "streetD": "Apt. 980", + "city": "East Allan", + "state": "Nebraska", + "country": "Liechtenstein", + "zipcode": "08027", + "geo": { "lat": "3.4797", "lng": "-123.6115" } + }, + "phone": "(015) 568-3818 x649", + "website": "lysanne.org", + "company": { + "name": "Funk - Nicolas", + "catchPhrase": "Face to face dedicated moratorium", + "bs": "turn-key benchmark web services" + }, + "posts": [ + { + "words": "enim molestias architecto", + "sentence": "Beatae repellat deserunt eos.", + "sentences": "Vero quae laudantium. Vel autem corrupti eligendi. Reiciendis itaque delectus deserunt ea error molestiae aperiam.", + "paragraph": "Et sed nostrum placeat debitis maiores. Eos illum qui qui necessitatibus. Officiis a quisquam labore." + }, + { + "words": "qui dolor nihil", + "sentence": "Occaecati asperiores rerum magni aspernatur eius id officiis.", + "sentences": "Explicabo accusantium enim consequatur. Repellat placeat hic facere natus sint velit eligendi est distinctio.", + "paragraph": "Fugiat maiores corrupti similique laboriosam enim culpa maiores velit. Distinctio consequatur illo commodi fuga quo repellendus. Nihil sequi dolor non. Nihil et blanditiis rerum cupiditate est et facilis aliquam." + }, + { + "words": "nesciunt iusto qui", + "sentence": "Sapiente commodi facere laborum aut.", + "sentences": "Molestias nemo fugiat itaque expedita est aspernatur praesentium explicabo repellat. Ea incidunt quia sint cupiditate saepe et tempora. Autem doloribus dolor eius omnis dolor. Eos laborum nesciunt iste rem placeat ut autem. Commodi error est non sapiente a.", + "paragraph": "Eius maxime enim ut repellendus illum eum aut blanditiis. Quaerat qui omnis ab qui ipsum sint. Officiis iste neque ab qui dolor doloremque rerum quos sed." + } + ], + "accountHistory": [ + { + "amount": "251.84", + "date": "2012-02-02T08:00:00.000Z", + "business": "Breitenberg - Turcotte", + "name": "Checking Account 0226", + "type": "payment", + "account": "66727594" + }, + { + "amount": "740.75", + "date": "2012-02-02T08:00:00.000Z", + "business": "Shields - Heller", + "name": "Checking Account 3782", + "type": "invoice", + "account": "64889716" + }, + { + "amount": "378.68", + "date": "2012-02-02T08:00:00.000Z", + "business": "Dickens and Sons", + "name": "Home Loan Account 1699", + "type": "withdrawal", + "account": "69892278" + } + ] +} +``` + +## Contextual Card + +Returns an object where the name, username, and email are self-referrential. + +```js +faker.helpers.contextualCard(); +``` + +```json +{ + "name": "Joan", + "username": "Joan39", + "avatar": "https://s3.amazonaws.com/uifaces/faces/twitter/ripplemdk/128.jpg", + "email": "Joan39_Weimann93@gmail.com", + "dob": "1973-09-26T20:12:25.191Z", + "phone": "650-151-6699 x271", + "address": { + "street": "Boyle Points", + "suite": "Apt. 093", + "city": "Julioville", + "zipcode": "79041", + "geo": { "lat": "63.9355", "lng": "-150.2784" } + }, + "website": "laurianne.info", + "company": { + "name": "Hudson and Sons", + "catchPhrase": "Streamlined transitional firmware", + "bs": "value-added incentivize communities" + } +} +``` + +## User Card + +Returns an object representing a user. + +```js +faker.helpers.userCard(); +``` + +```json +{ + "name": "Adriel Dach", + "username": "Lawson.Rutherford83", + "email": "Kassandra86@gmail.com", + "address": { + "street": "Gislason View", + "suite": "Apt. 409", + "city": "Tellyside", + "zipcode": "00051", + "geo": { "lat": "69.6104", "lng": "-109.3244" } + }, + "phone": "1-685-232-7348", + "website": "dakota.org", + "company": { + "name": "DuBuque Group", + "catchPhrase": "Mandatory multi-state ability", + "bs": "real-time grow methodologies" + } +} +``` + +## Create Transaction + +Returns an object representing a transaction. + +```js +faker.helpers.createTransaction(); +``` + +```json +{ + "amount": "883.74", + "date": "2012-02-02T08:00:00.000Z", + "business": "Brakus LLC", + "name": "Credit Card Account 9671", + "type": "deposit", + "account": "54758588" +} +``` diff --git a/docs/api/image.md b/docs/api/image.md new file mode 100644 index 00000000..1556ab34 --- /dev/null +++ b/docs/api/image.md @@ -0,0 +1,318 @@ +# Image + +[[toc]] + +## Image + +Return [lorempixel](http://lorempixel.com/) url + +::: tip +| Param | Type | Default | +| --------- | ------- | :-----: | +| width | number | `640` | +| height | number | `480` | +| randomize | boolean | `false` | +::: + +```js +faker.image.image(); // http://lorempixel.com/640/480/nightlife +faker.image.image(200); // http://lorempixel.com/200/480/sports +faker.image.image(200, 600); // http://lorempixel.com/200/600/animals +faker.image.image(200, 600, true); // http://lorempixel.com/200/600/transport?12438 +``` + +## Avatar + +Return random avatar url + +```js +faker.image.avatar(); // https://s3.amazonaws.com/uifaces/faces/twitter/martip07/128.jpg +``` + +## Data URI + +Return random data uri + +::: tip +| Param | Type | Default | +| ------ | ------ | :-----: | +| width | number | `null` | +| height | number | `null` | +::: + +```js +faker.image.dataUri(); +// data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20version%3D%221.1%22%20baseProfile%3D%22full%22%20width%3D%22undefined%22%20height%3D%22undefined%22%3E%20%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22grey%22%2F%3E%20%20%3Ctext%20x%3D%220%22%20y%3D%2220%22%20font-size%3D%2220%22%20text-anchor%3D%22start%22%20fill%3D%22white%22%3Eundefinedxundefined%3C%2Ftext%3E%20%3C%2Fsvg%3E +``` + +## Image URL + +Return [lorempixel](http://lorempixel.com/) url + +::: tip +| Param | Type | Default | +| --------- | ------- | :-----: | +| width | number | `640` | +| height | number | `480` | +| category | string | `480` | +| randomize | boolean | `false` | +| https | boolean | `false` | + +**Category Options:** `abstract` `animals` `business` `cats` `city` `food` `nightlife` `fashion` `people` `nature` `sports` `technics` `transport` +::: + +```js +faker.image.imageUrl(); // http://lorempixel.com/640/480 +faker.image.imageUrl(200); // http://lorempixel.com/200/480 +faker.image.imageUrl(200, 600); // http://lorempixel.com/200/600 +faker.image.imageUrl(200, 600, 'animals'); // http://lorempixel.com/200/600/animals +faker.image.imageUrl(200, 600, 'animals', true); // http://lorempixel.com/200/600/animals?3853 +faker.image.imageUrl(200, 600, 'animals', true, true); // https://lorempixel.com/200/600/animals?98461 +``` + +## Abstract Image + +Return [lorempixel](http://lorempixel.com/) url from abstract category + +::: tip +| Param | Type | Default | +| --------- | ------- | :-----: | +| width | number | `640` | +| height | number | `480` | +| randomize | boolean | `false` | +::: + +```js +faker.image.abstract(); // http://lorempixel.com/640/480/abstract +faker.image.abstract(200); // http://lorempixel.com/200/480/abstract +faker.image.abstract(200, 600); // http://lorempixel.com/200/600/abstract +faker.image.abstract(200, 600, true); // http://lorempixel.com/200/600/abstract?89872 +``` + +## Animal Image + +Return [lorempixel](http://lorempixel.com/) url from animals category + +::: tip +| Param | Type | Default | +| --------- | ------- | :-----: | +| width | number | `640` | +| height | number | `480` | +| randomize | boolean | `false` | +::: + +```js +faker.image.animals(); // http://lorempixel.com/640/480/animals +faker.image.animals(200); // http://lorempixel.com/200/480/animals +faker.image.animals(200, 600); // http://lorempixel.com/200/600/animals +faker.image.animals(200, 600, true); // http://lorempixel.com/200/600/animals?89872 +``` + +## Business Image + +Return [lorempixel](http://lorempixel.com/) url from business category + +::: tip +| Param | Type | Default | +| --------- | ------- | :-----: | +| width | number | `640` | +| height | number | `480` | +| randomize | boolean | `false` | +::: + +```js +faker.image.business(); // http://lorempixel.com/640/480/business +faker.image.business(200); // http://lorempixel.com/200/480/business +faker.image.business(200, 600); // http://lorempixel.com/200/600/business +faker.image.business(200, 600, true); // http://lorempixel.com/200/600/business?89872 +``` + +## Cat Image + +Return [lorempixel](http://lorempixel.com/) url from cats category + +::: tip +| Param | Type | Default | +| --------- | ------- | :-----: | +| width | number | `640` | +| height | number | `480` | +| randomize | boolean | `false` | +::: + +```js +faker.image.cats(); // http://lorempixel.com/640/480/cats +faker.image.cats(200); // http://lorempixel.com/200/480/cats +faker.image.cats(200, 600); // http://lorempixel.com/200/600/cats +faker.image.cats(200, 600, true); // http://lorempixel.com/200/600/cats?89872 +``` + +## City Image + +Return [lorempixel](http://lorempixel.com/) url from city category + +::: tip +| Param | Type | Default | +| --------- | ------- | :-----: | +| width | number | `640` | +| height | number | `480` | +| randomize | boolean | `false` | +::: + +```js +faker.image.city(); // http://lorempixel.com/640/480/city +faker.image.city(200); // http://lorempixel.com/200/480/city +faker.image.city(200, 600); // http://lorempixel.com/200/600/city +faker.image.city(200, 600, true); // http://lorempixel.com/200/600/city?89872 +``` + +## Food Image + +Return [lorempixel](http://lorempixel.com/) url from food category + +::: tip +| Param | Type | Default | +| --------- | ------- | :-----: | +| width | number | `640` | +| height | number | `480` | +| randomize | boolean | `false` | +::: + +```js +faker.image.food(); // http://lorempixel.com/640/480/food +faker.image.food(200); // http://lorempixel.com/200/480/food +faker.image.food(200, 600); // http://lorempixel.com/200/600/food +faker.image.food(200, 600, true); // http://lorempixel.com/200/600/food?89872 +``` + +## Nightlife Image + +Return [lorempixel](http://lorempixel.com/) url from nightlife category + +::: tip +| Param | Type | Default | +| --------- | ------- | :-----: | +| width | number | `640` | +| height | number | `480` | +| randomize | boolean | `false` | +::: + +```js +faker.image.nightlife(); // http://lorempixel.com/640/480/nightlife +faker.image.nightlife(200); // http://lorempixel.com/200/480/nightlife +faker.image.nightlife(200, 600); // http://lorempixel.com/200/600/nightlife +faker.image.nightlife(200, 600, true); // http://lorempixel.com/200/600/nightlife?89872 +``` + +## Fashion Image + +Return [lorempixel](http://lorempixel.com/) url from fashion category + +::: tip +| Param | Type | Default | +| --------- | ------- | :-----: | +| width | number | `640` | +| height | number | `480` | +| randomize | boolean | `false` | +::: + +```js +faker.image.fashion(); // http://lorempixel.com/640/480/fashion +faker.image.fashion(200); // http://lorempixel.com/200/480/fashion +faker.image.fashion(200, 600); // http://lorempixel.com/200/600/fashion +faker.image.fashion(200, 600, true); // http://lorempixel.com/200/600/fashion?89872 +``` + +## People Image + +Return [lorempixel](http://lorempixel.com/) url from people category + +::: tip +| Param | Type | Default | +| --------- | ------- | :-----: | +| width | number | `640` | +| height | number | `480` | +| randomize | boolean | `false` | +::: + +```js +faker.image.people(); // http://lorempixel.com/640/480/people +faker.image.people(200); // http://lorempixel.com/200/480/people +faker.image.people(200, 600); // http://lorempixel.com/200/600/people +faker.image.people(200, 600, true); // http://lorempixel.com/200/600/people?89872 +``` + +## Nature Image + +Return [lorempixel](http://lorempixel.com/) url from nature category + +::: tip +| Param | Type | Default | +| --------- | ------- | :-----: | +| width | number | `640` | +| height | number | `480` | +| randomize | boolean | `false` | +::: + +```js +faker.image.nature(); // http://lorempixel.com/640/480/nature +faker.image.nature(200); // http://lorempixel.com/200/480/nature +faker.image.nature(200, 600); // http://lorempixel.com/200/600/nature +faker.image.nature(200, 600, true); // http://lorempixel.com/200/600/nature?89872 +``` + +## Sports Image + +Return [lorempixel](http://lorempixel.com/) url from sports category + +::: tip +| Param | Type | Default | +| --------- | ------- | :-----: | +| width | number | `640` | +| height | number | `480` | +| randomize | boolean | `false` | +::: + +```js +faker.image.sports(); // http://lorempixel.com/640/480/sports +faker.image.sports(200); // http://lorempixel.com/200/480/sports +faker.image.sports(200, 600); // http://lorempixel.com/200/600/sports +faker.image.sports(200, 600, true); // http://lorempixel.com/200/600/sports?89872 +``` + +## Technics Image + +Return [lorempixel](http://lorempixel.com/) url from technics category + +::: tip +| Param | Type | Default | +| --------- | ------- | :-----: | +| width | number | `640` | +| height | number | `480` | +| randomize | boolean | `false` | +::: + +```js +faker.image.technics(); // http://lorempixel.com/640/480/technics +faker.image.technics(200); // http://lorempixel.com/200/480/technics +faker.image.technics(200, 600); // http://lorempixel.com/200/600/technics +faker.image.technics(200, 600, true); // http://lorempixel.com/200/600/technics?89872 +``` + +## Transport Image + +Return [lorempixel](http://lorempixel.com/) url from transport category + +::: tip +| Param | Type | Default | +| --------- | ------- | :-----: | +| width | number | `640` | +| height | number | `480` | +| randomize | boolean | `false` | +::: + +```js +faker.image.transport(); // http://lorempixel.com/640/480/transport +faker.image.transport(200); // http://lorempixel.com/200/480/transport +faker.image.transport(200, 600); // http://lorempixel.com/200/600/transport +faker.image.transport(200, 600, true); // http://lorempixel.com/200/600/transport?89872 +``` diff --git a/docs/api/internet.md b/docs/api/internet.md new file mode 100644 index 00000000..3053881e --- /dev/null +++ b/docs/api/internet.md @@ -0,0 +1,186 @@ +# Internet + +[[toc]] + +## Avatar + +return random avatar url + +```js +faker.internet.avatar(); +// https://s3.amazonaws.com/uifaces/faces/twitter/dnezkumar/128.jpg +``` + +## Example E-mail + +Generates random email address from [safe domains](https://en.wikipedia.org/wiki/Example.com) + +::: tip +| Param | Type | Default | +| --------- | ------ | :----------------------: | +| firstName | string | `faker.name.firstName()` | +| lastName | string | `faker.name.lastName()` | +::: + +```js +faker.internet.exampleEmail(); // Rhiannon_Von81@example.com +faker.internet.exampleEmail('bob'); // bob26@example.net +faker.internet.exampleEmail('bob', 'jon'); // bob_jon@example.com +``` + +## E-mail + +Generates random email address + +::: danger +This uses real domains so it is likely to create a "real" email address. Use `exampleEmail()` to be safe. +::: + +::: tip +| Param | Type | Default | +| --------- | ------ | :-----------------------------------: | +| firstName | string | `faker.name.firstName()` | +| lastName | string | `faker.name.lastName()` | +| provider | string | `gmail.com` `yahoo.com` `hotmail.com` | +::: + +```js +faker.internet.email(); // Ottis_Cremin16@yahoo.com +faker.internet.email('bob'); // bob_jon@example.com +faker.internet.email('bob', 'jon'); // bob_jon73@hotmail.com +faker.internet.email('bob', 'jon', 'somedomain.com'); // bob_jon@somedomain.com +``` + +## User Name + +Generates a username based on one of several patterns. + +The pattern is chosen randomly from one of the following: `firstname#` `firstname.lastname` `firstname.lastname#` `firstnamelastname` `firstnamelastname#` + +::: tip +| Param | Type | Default | +| --------- | ------ | :----------------------: | +| firstName | string | `faker.name.firstName()` | +| lastName | string | `faker.name.lastName()` | +::: + +```js +faker.internet.userName(); // Maci12 +faker.internet.userName('bob')); // bob_Considine30 +faker.internet.userName('bob', 'jon')); // bob.jon61 +``` + +## Protocol + +Randomly generates http or https + +```js +faker.internet.protocol(); // https +``` + +## URL + +Generates a random URL. The URL could be secure or insecure. + +```js +faker.internet.url(); // http://chloe.net +``` + +## Domain Name + +Generates a random domain name. + +```js +faker.internet.domainName(); // hailie.biz +``` + +## Domain Suffix + +Generates a random domain suffix. + +```js +faker.internet.domainSuffix(); // org +``` + +## Domain Word + +Generates a random domain word. + +```js +faker.internet.domainWord(); // mattie +``` + +## IP Address + +Generates a random IP. + +```js +faker.internet.ip(); // 165.20.179.86 +``` + +## IPV6 + +Generates a random IPv6 address. + +```js +faker.internet.ipv6(); // 0e1a:48d6:8da6:b933:be58:442d:71db:42d7 +``` + +## User Agent + +Generates a random user agent. + +```js +faker.internet.userAgent(); +// Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20100101 Firefox/6.0.0 +``` + +## Hexadecimal Color + +Generates a random hexadecimal color based on [this awesome response](http://stackoverflow.com/questions/43044/algorithm-to-randomly-generate-an-aesthetically-pleasing-color-palette) + +::: tip +| Param | Type | Default | +| ------------ | ------ | :-----: | +| baseRed255 | number | `0` | +| baseGreen255 | number | `0` | +| baseBlue255 | number | `0` | +::: + +```js +faker.internet.color(); // #630c7b +faker.internet.color(128); // #910145 +faker.internet.color(122, 148); // #a06a09 +faker.internet.color(42, 22, 11); // #48166d +``` + +## MAC Address + +Generates a random mac address. + +```js +faker.internet.mac(); // 00:87:14:24:31:ba +``` + +## Password + +Generates a random password. + +::: tip +| Param | Type | Default | +| --------- | ------- | :-----: | +| len | number | `15` | +| memorable | boolean | `false` | +| pattern | regex | `/\w/` | +| prefix | string | `''` | + +**Note:** `pattern` param is ignored if memorable is set to `true` +::: + +```js +faker.internet.password(); // 0ViHvR3Qp7AAsir +faker.internet.password(8); // m9Qw6dzR +faker.internet.password(8, true); // qecuquha +faker.internet.password(8, false, /^[A-Z]*$/); // PQGGVATB +faker.internet.password(8, false, /^[A-Z]*$/, 'bob'); // bobTXMPD +``` diff --git a/docs/api/localization.md b/docs/api/localization.md new file mode 100644 index 00000000..dbd03b43 --- /dev/null +++ b/docs/api/localization.md @@ -0,0 +1,67 @@ +# Localization + +As of version `v2.0.0` Faker has support for multiple localities. + +The default language locale is set to English. + +Setting a new locale is simple: + +```js +// sets locale to de +faker.setLocale('de'); +// or +faker.locale = 'de'; +``` + +- az +- cz +- de +- de_AT +- de_CH +- en +- en_AU +- en_BORK +- en_CA +- en_GB +- en_IE +- en_IND +- en_US +- en_ZA +- en_au_ocker +- es +- es_MX +- fa +- fr +- fr_CA +- ge +- id_ID +- it +- ja +- ko +- nb_NO +- nep +- nl +- pl +- pt_BR +- pt_PT +- ru +- sk +- sv +- tr +- uk +- vi +- zh_CN +- zh_TW + +## Individual Localization Packages + +As of version `v3.0.0` Faker supports incremental loading of locales. + +By default, requiring `faker` will include _all_ locale data. + +In a production environment, you may only want to include the locale data for a specific set of locales. + +```js +// loads only de locale +const faker = require('faker/locale/de'); +``` diff --git a/docs/guide/index.md b/docs/guide/index.md new file mode 100644 index 00000000..18f6c87d --- /dev/null +++ b/docs/guide/index.md @@ -0,0 +1,64 @@ +# Getting Started + +## Overview + +Faker is a popular library that generates fake (but reasonable) data that can be used for things such as: + +- Unit Testing +- Performance Testing +- Building Demos +- Working without a completed backend + +Faker was originally written in [Perl](https://metacpan.org/dist/Data-Faker) and this is the JavaScript port. Language bindings also exist for [Ruby](https://github.com/faker-ruby/faker), [Java](https://github.com/DiUS/java-faker), and [Python](https://github.com/joke2k/faker). + +This documentation only covers the JavaScript implementation of Faker. + +## Environments + +You can run Faker in the Browser, within Node, or the many other languages supported by Faker. ([Perl](https://metacpan.org/dist/Data-Faker), [Ruby](https://github.com/faker-ruby/faker), [Java](https://github.com/DiUS/java-faker), and [Python](https://github.com/joke2k/faker)) + +## Installation + +Install it as a Dev Dependency using your favorite package manager. + +```shell +npm install @faker-js/faker --save-dev +``` + +## Usage + +### Node.js + +```js +import faker from 'faker'; + +const randomName = faker.name.findName(); // Rowan Nikolaus +const randomEmail = faker.internet.email(); // Kassandra.Haley@erich.biz +const randomCard = faker.helpers.createCard(); // An object representing a random contact card containing many properties +``` + +### Browser + +```html + + + +``` + +:::tip Note +Using the browser is great for experimenting 👍. However, due to all of the strings Faker uses to generate fake data, **Faker is a large package**. It's around `1.57 MB` minified. **Please avoid deploying Faker in your web app.** +::: + +## Community + +If you have questions or need help, reach out to the community via Discord and GitHub Discussions. diff --git a/docs/guide/recent-faqs.md b/docs/guide/recent-faqs.md new file mode 100644 index 00000000..89a114b2 --- /dev/null +++ b/docs/guide/recent-faqs.md @@ -0,0 +1,52 @@ +# Recent Statement and FAQs + +_January 11th, 2022_ + +Due to recent events, folks may have some questions or concerns about the future of Faker. + +Here are some answers. + +## What happened? + +In short, the author deleted the original repository in protest against large companies who did not pay him for maintaining Faker. + +In response to all that happened, we have created an entirely new GitHub Organization for the packages and ecosystem under the namespace [faker-js](https://github.com/faker-js). + +:::tip Support Open Source Software + +🙏 Please ask your company to do their part in sponsoring Open Source projects and contributors. + +Seriously, you don't have to sponsor _this_ project, just start having the conversation with your engineering leadership. +::: + +## Are these the official docs? + +**Yes**. This is the official site and documentation for the Faker library. + +## Who maintains Faker now? + +**Faker is now maintained by the organization [faker-js](https://github.com/faker-js)** after the original repository was deleted by the author. + +## My build broke. Help. + +If you have installed `faker` from npm, please uninstall it and migrate to `@faker-js/faker`. Due to the above issues, version 6 of faker.js **does not run** and is why the `@faker-js/faker` package exists. + +We will be releasing a new version shortly. + +**NPM** + +```shell +npm install @faker-js/faker --save-dev +``` + +**Yarn** + +```shell +yarn add @faker-js/faker -D +``` + +**pnpm** + +```shell +pnpm add -D @faker-js/faker +``` diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 00000000..aed22725 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,24 @@ +--- +home: true +title: 'Faker' +actionText: Get Started +actionLink: /guide/ + +# altActionText: Playground +# altActionLink: /playground/ + +features: + - title: 👠 Products + details: Generate Prices, Product Names, Adjectives, and Descriptions. + - title: 💸 Finance + details: Create stubbed out Account Details, Transactions, and Crypto Addresses. + - title: 💌 Addresses + details: Generate valid Addresses, Zip Codes, Street Names, States, and Countries! + - title: 👾 Hacker Jargon + details: “Try to reboot the SQL bus, maybe it will bypass the virtual application!” + - title: ⏰ Time-based Data + details: Past, present, future, recent, soon... whenever! + - title: 🌏 Localization + details: Set a locale to generate realistic looking Names, Addresses, and Phone Numbers. +footer: MIT Licensed 2022 +--- diff --git a/docs/playground/index.md b/docs/playground/index.md new file mode 100644 index 00000000..db887d42 --- /dev/null +++ b/docs/playground/index.md @@ -0,0 +1,5 @@ +--- +sidebar: false +--- + + diff --git a/docs/public/logo.svg b/docs/public/logo.svg new file mode 100644 index 00000000..a44f3898 --- /dev/null +++ b/docs/public/logo.svg @@ -0,0 +1,4 @@ + + + + -- cgit v1.2.3