diff options
| author | Jess <[email protected]> | 2022-01-12 19:48:48 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-01-12 19:48:48 -0500 |
| commit | 71e902599651b645cdb6996c8cd562e8007a32ea (patch) | |
| tree | 368e83ffbeb836d5c66ad7af53c765c7444a26cb /docs/api/internet.md | |
| parent | a590f266e02d8f8a2cac65cb6e8bd395bf04074b (diff) | |
| download | faker-71e902599651b645cdb6996c8cd562e8007a32ea.tar.xz faker-71e902599651b645cdb6996c8cd562e8007a32ea.zip | |
feat: adding documentation with vitepress (#80)
Diffstat (limited to 'docs/api/internet.md')
| -rw-r--r-- | docs/api/internet.md | 186 |
1 files changed, 186 insertions, 0 deletions
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 +``` |
