diff options
Diffstat (limited to 'docs/api')
| -rw-r--r-- | docs/api/address.md | 181 | ||||
| -rw-r--r-- | docs/api/commerce.md | 62 | ||||
| -rw-r--r-- | docs/api/company.md | 106 | ||||
| -rw-r--r-- | docs/api/database.md | 35 | ||||
| -rw-r--r-- | docs/api/datatype.md | 125 | ||||
| -rw-r--r-- | docs/api/date.md | 129 | ||||
| -rw-r--r-- | docs/api/fake.md | 11 | ||||
| -rw-r--r-- | docs/api/finance.md | 167 | ||||
| -rw-r--r-- | docs/api/hacker.md | 51 | ||||
| -rw-r--r-- | docs/api/helpers.md | 262 | ||||
| -rw-r--r-- | docs/api/image.md | 318 | ||||
| -rw-r--r-- | docs/api/internet.md | 186 | ||||
| -rw-r--r-- | docs/api/localization.md | 67 |
13 files changed, 1700 insertions, 0 deletions
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 <Badge text="5.0.0+" type="tip" vertical="middle"/> +| 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 <Badge text="5.0.0+" type="tip" vertical="middle"/> +| 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 <Badge text="5.0.0+" type="tip" vertical="middle"/> + +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 <Badge text="5.5.0+" type="tip" vertical="middle"/> + +[[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 | <Badge text="N/A" type="error" vertical="middle"/> | +| to | Date | <Badge text="N/A" type="error" vertical="middle"/> | +::: + +```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 <Badge text="5.0.0+" type="tip" vertical="middle"/> + +Returns some date recent date + +::: tip +| Param | Type | Default | +| ------- | ------- | :----------: | +| days | number | `1` | +| refDate | Date | `new Date()` | +::: + +```js +faker.date.recent(); +``` + +## Soon <Badge text="5.0.0+" type="tip" vertical="middle"/> + +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 <Badge text="5.0.0+" type="tip" vertical="middle"/> + +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 <Badge text="5.0.0+" type="tip" vertical="middle"/> + +Return random credit card number + +::: tip +| Param | Type | Default | +| -------- | ------ | :-----: | +| provider | string | `''` | +::: + +```js +faker.finance.creditCardNumber(); +``` + +## Credit Card CVV <Badge text="5.0.0+" type="tip" vertical="middle"/> + +Return random credit card CVV + +```js +faker.finance.creditCardCVV(); +``` + +## Bitcoin Address + +Return random bitcoin address + +```js +faker.finance.bitcoinAddress(); // 3FINQD7C6JW7XPF4NMNHOJYAXLKLP +``` + +## Ethereum Address <Badge text="5.0.0+" type="tip" vertical="middle"/> + +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'); // [email protected] +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": "[email protected]", + "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": "[email protected]", + "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": "[email protected]", + "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 <Badge type="tip" vertical="middle" text="Recommended" /> + +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(); // [email protected] +faker.internet.exampleEmail('bob'); // [email protected] +faker.internet.exampleEmail('bob', 'jon'); // [email protected] +``` + +## E-mail <Badge type="danger" vertical="middle" text="Not recommended" /> + +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(); // [email protected] +faker.internet.email('bob'); // [email protected] +faker.internet.email('bob', 'jon'); // [email protected] +faker.internet.email('bob', 'jon', 'somedomain.com'); // [email protected] +``` + +## 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'); +``` |
