diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
new file mode 100644
index 0000000..9c32df6
--- /dev/null
+++ b/.github/workflows/docs.yml
@@ -0,0 +1,37 @@
+name: Docs
+on:
+ push:
+ branches: [master, feat-js-like-api]
+ paths:
+ - .github/workflows/docs.yml
+ - index.js
+ - index.d.ts
+ - tsconfig.json
+
+jobs:
+ docs:
+ name: Docs
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Check out code
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Install bun
+ uses: oven-sh/setup-bun@v1
+ - name: Generate API doc
+ run: bun x typedoc
+ - name: Copy index.js
+ run: cp index.js build/docs/
+
+ - name: Setup Pages
+ uses: actions/configure-pages@v4
+ - name: Upload artifact
+ uses: actions/upload-pages-artifact@v2
+ with:
+ path: "build/docs"
+ - name: Deploy to GitHub Pages
+ id: deployment
+ uses: actions/deploy-pages@v3
diff --git a/.gitignore b/.gitignore
index 6197dc0..695a2d4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
/k6
*_skeleton.go
-/build
\ No newline at end of file
+/build
+/node_modules
+yarn.lock
\ No newline at end of file
diff --git a/README.md b/README.md
index 208a8c3..9ea6d5a 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,8 @@
-xk6-faker
-=========
+[![Go Report Card](https://goreportcard.com/badge/github.com/szkiba/xk6-faker)](https://goreportcard.com/report/github.com/szkiba/xk6-faker)
+[![GitHub Actions](https://github.com/szkiba/xk6-faker/actions/workflows/test.yml/badge.svg)](https://github.com/szkiba/xk6-faker/actions/workflows/test.yml)
+[![API Reference](https://img.shields.io/badge/API-reference-blue?logo=readme&logoColor=lightgray)](https://ivan.szkiba.hu/xk6-faker)
+
+# xk6-faker
**Random fake data generator for k6.**
@@ -7,10 +10,11 @@ Altought there is several good JavaScript fake data generator, but using these a
For convenience, the xk6-faker API resembles the popular [Faker.js](https://fakerjs.dev/) API as much as possible. Random data of the same type can be generated in the same way. A subset of the [Faker.js](https://fakerjs.dev/) API has been implemented in a simplified form.
-Example
+Check out the API documentation [here](https://ivan.szkiba.hu/xk6-faker).
+
+**Example**
-For convenient use, the default export of the module is a Faker instance,
-it just needs to be imported and it is ready for use.
+For convenient use, the default export of the module is a Faker instance, it just needs to be imported and it is ready for use.
```ts
import faker from "k6/x/faker"
@@ -19,8 +23,10 @@ export default function() {
console.log(faker.person.firstName()) // prints a random first name
}
```
+
For a reproducible test run, a random seed value can be passed to the constructor of the Faker class.
+
```ts
import { Faker } from "k6/x/faker"
@@ -30,12 +36,16 @@ export default function() {
console.log(faker.person.firstName()) // always prints 'Josiah'
}
```
+
The reproducibility of the test can also be achieved using the default Faker instance,
if the seed value is set in the `XK6_FAKER_SEED` environment variable.
+
```bash
k6 run --env XK6_FAKER_SEED=11 script.js
```
+
then
+
```ts
import faker from "k6/x/faker"
@@ -44,16 +54,16 @@ export default function() {
}
```
-
+The [examples](https://github.com/szkiba/xk6-faker/blob/master/examples) directory contains examples of how to use the xk6-faker extension. A k6 binary containing the xk6-faker extension is required to run the examples.
-The [examples](https://github.com/szkiba/xk6-faker/blob/master/examples) directory contains examples of how to use the xk6-faker extension. A k6 binary containing the xk6-faker extension is required to run the examples. *If the search path also contains the k6 command, don't forget to specify which k6 you want to run (for example `./k6`\)*.
+> [!IMPORTANT]
+> If the search path also contains the k6 command, don't forget to specify which k6 you want to run (for example `./k6`).
**Download**
You can download pre-built k6 binaries from the [Releases](https://github.com/szkiba/xk6-faker/releases/) page. Check the [Packages](https://github.com/szkiba/xk6-faker/pkgs/container/xk6-faker) page for pre-built k6 Docker images.
-
-Build
+**Build**
The [xk6](https://github.com/grafana/xk6) build tool can be used to build a k6 that will include xk6-faker extension:
@@ -62,2323 +72,3 @@ $ xk6 build --with github.com/szkiba/xk6-faker@latest
```
For more build options and how to use xk6, check out the [xk6 documentation]([xk6](https://github.com/grafana/xk6)).
-
-
-
-API
-===
-
-Faker
------
-
-This is Faker's main class containing all generators that can be used to generate data.
-
-Please have a look at the individual generators and methods for more information and examples.
-
-Example
-
-```ts
-import { Faker } from "k6/x/faker"
-
-const faker = new Faker(11)
-
-export default function() {
- console.log(faker.person.firstName()) // 'Josiah'
-}
-```
-
-
-
-### Faker()
-
-```ts
-constructor(seed?: int64);
-```
-
-- `seed` random seed value for deterministic generator
-
-Creates a new instance of Faker.
-
-Optionally, the value of the random seed can be set as a constructor parameter. This is intended to allow for consistent values in a tests, so you might want to use hardcoded values as the seed.
-
-Please note that generated values are dependent on both the seed and the number of calls that have been made.
-
-Setting seed to 0 (or omitting it) will use seed derived from system entropy.
-
-Example
-
-```ts
-const consistentFaker = new Faker(11)
-const semiRandomFaker = new Faker()
-```
-
-
-
-### Faker.person
-
-```ts
-readonly person: Person;
-```
-
-Generator to generate people's personal information such as names and job titles.
-
-### Faker.company
-
-```ts
-readonly company: Company;
-```
-
-Generator to generate company related entries.
-
-### Faker.hacker
-
-```ts
-readonly hacker: Hacker;
-```
-
-Generator to generate hacker/IT words and phrases.
-
-### Faker.hipster
-
-```ts
-readonly hipster: Hipster;
-```
-
-Generator to generate hipster words, phrases and paragraphs.
-
-### Faker.lorem
-
-```ts
-readonly lorem: Lorem;
-```
-
-Generator to generate random words, sentences, paragraphs, questions and quotes.
-
-### Faker.internet
-
-```ts
-readonly internet: Internet;
-```
-
-Generator to generate internet related entries.
-
-### Faker.finance
-
-```ts
-readonly finance: Finance;
-```
-
-Generator to generate finance and money related entries.
-
-### Faker.phone
-
-```ts
-readonly phone: Phone;
-```
-
-Generator to generate phone-related data.
-
-### Faker.vehicle
-
-```ts
-readonly vehicle: Vehicle;
-```
-
-Generator to generate vehicle related entries.
-
-### Faker.color
-
-```ts
-readonly color: Color;
-```
-
-Generator to generate colors.
-
-### Faker.location
-
-```ts
-readonly location: Location;
-```
-
-Generator to generate addresses and locations.
-
-### Faker.datetime
-
-```ts
-readonly datetime: DateTime;
-```
-
-Generator to generate dates and times.
-
-### Faker.numbers
-
-```ts
-readonly numbers: Numbers;
-```
-
-Generator to generate numbers of any kind.
-
-### Faker.strings
-
-```ts
-readonly strings: Strings;
-```
-
-Generator to generate string related entries.
-
-### Faker.helpers
-
-```ts
-readonly helpers: Helpers;
-```
-
-Various helper methods.
-
-Person
-------
-
-Generator to generate people's personal information such as names and job titles.
-
-### Person.firstName()
-
-```ts
-firstName(): string;
-```
-
-Generates a random first name.
-
-*Returns a random first name*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.person.firstName() // 'Josiah'
-```
-
-
-
-### Person.lastName()
-
-```ts
-lastName(): string;
-```
-
-Generates a random last name.
-
-*Returns a random last name*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.person.lastName() // 'Abshire'
-```
-
-
-
-### Person.prefix()
-
-```ts
-prefix(): string;
-```
-
-Generates a random person prefix.
-
-*Returns a random person prefix.*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.person.prefix() // 'Mr.'
-```
-
-
-
-### Person.suffix()
-
-```ts
-suffix(): string;
-```
-
-Generates a random person suffix.
-
-*Returns a random person suffix*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.person.suffix() // 'Sr.'
-```
-
-
-
-### Person.sexType()
-
-```ts
-sexType(): string;
-```
-
-Generates a random sex type.
-
-*Returns a random sex type `male`|`female`*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.person.sexType() // 'male'
-```
-
-
-
-### Person.jobTitle()
-
-```ts
-jobTitle(): string;
-```
-
-Generates a random job title.
-
-*Returns a random job title*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.person.jobTitle() // 'Representative'
-```
-
-
-
-### Person.jobLevel()
-
-```ts
-jobLevel(): string;
-```
-
-Generates a random job level.
-
-*Returns a random job level*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.person.jobLevel() // 'Identity'
-```
-
-
-
-### Person.jobDescriptor()
-
-```ts
-jobDescriptor(): string;
-```
-
-Generates a random job descriptor.
-
-*Returns a random job descriptor*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.person.jobDescriptor() // 'Internal'
-```
-
-
-
-Company
--------
-
-Generator to generate company related entries.
-
-### Company.name()
-
-```ts
-name(): string;
-```
-
-Generates a random company name string.
-
-*Returns a random company name string*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.company.name() // 'Xatori'
-```
-
-
-
-### Company.suffix()
-
-```ts
-suffix(): string;
-```
-
-Generates a random company suffix string.
-
-*Returns a random company suffix string*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.company.suffix() // 'LLC'
-```
-
-
-
-### Company.buzzWord()
-
-```ts
-buzzWord(): string;
-```
-
-Generates a random company buzz word string.
-
-*Returns a random company buzz word string*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.company.buzzWord() // 'Reverse-engineered'
-```
-
-
-
-### Company.bs()
-
-```ts
-bs(): string;
-```
-
-Generates a random company bs string.
-
-*Returns a random company bs string*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.company.bs() // '24-7'
-```
-
-
-
-Hacker
-------
-
-Generator to generate hacker/IT words and phrases.
-
-### Hacker.abbreviation()
-
-```ts
-abbreviation(): string;
-```
-
-Generates a random hacker/IT abbreviation.
-
-*Returns a random hacker/IT abbreviation*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.hacker.abbreviation() // 'Xatori'
-```
-
-
-
-### Hacker.adjective()
-
-```ts
-adjective(): string;
-```
-
-Generates a random hacker/IT adjective.
-
-*Returns a random hacker/IT adjective*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.hacker.adjective() // 'Xatori'
-```
-
-
-
-### Hacker.ingverb()
-
-```ts
-ingverb(): string;
-```
-
-Generates a random hacker/IT verb for continuous actions (en: ing suffix; e.g. hacking).
-
-*Returns a random hacker/IT verb for continuous actions*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.hacker.ingverb() // 'Xatori'
-```
-
-
-
-### Hacker.noun()
-
-```ts
-noun(): string;
-```
-
-Generates a random hacker/IT noun.
-
-*Returns a random hacker/IT noun*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.hacker.noun() // 'Xatori'
-```
-
-
-
-### Hacker.phrase()
-
-```ts
-phrase(): string;
-```
-
-Generates a random hacker/IT phrase.
-
-*Returns a random hacker/IT phrase*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.hacker.phrase() // 'Xatori'
-```
-
-
-
-### Hacker.verb()
-
-```ts
-verb(): string;
-```
-
-Generates a random hacker/IT verb.
-
-*Returns a random hacker/IT verb*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.hacker.verb() // 'Xatori'
-```
-
-
-
-Hipster
--------
-
-Generator to generate hipster words, phrases and paragraphs.
-
-### Hipster.word()
-
-```ts
-word(): string;
-```
-
-Generates a single hipster word.
-
-*Returns a single hipster word*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.hipster.word() // 'Xatori'
-```
-
-
-
-### Hipster.sentence()
-
-```ts
-sentence(wordCount: int): string;
-```
-
-- `wordCount` the number of words
-
-Generates a random hipster sentence.
-
-*Returns a random hipster sentence*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.hipster.sentence(4) // 'Xatori'
-```
-
-
-
-### Hipster.paragraph()
-
-```ts
-paragraph(paragraphCount: int, sentenceCount: int, wordCount: int, separator: string): string;
-```
-
-- `paragraphCount` the number of paragraphs to generate
-
-- `sentenceCount` the number of sentences to generate
-
-- `wordCount` the number of words, that should be in the sentence
-
-- `separator` the paragraph separator
-
-Generates a random hipster paragraphs.
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.hipster.paragraph(1, 2, 4, "\n") // 'Xatori'
-```
-
-
-
-Lorem
------
-
-Generator to generate random words, sentences, paragraphs, questions and quotes.
-
-### Lorem.paragraph()
-
-```ts
-paragraph(paragraphCount: int, sentenceCount: int, wordCount: int, separator: string): string;
-```
-
-- `paragraphCount` the number of paragraphs to generate
-
-- `sentenceCount` the number of sentences to generate
-
-- `wordCount` the number of words, that should be in the sentence
-
-- `separator` the paragraph separator
-
-Generates the given number of paragraphs.
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.lorem.paragraph(1, 2, 4, "\n") // 'Quickly up brace lung. Anyway then bravo mirror.'
-```
-
-
-
-### Lorem.sentence()
-
-```ts
-sentence(wordCount: int): string;
-```
-
-- `wordCount` the number of words
-
-Generates a space separated list of words beginning with a capital letter and ending with a period.
-
-*Returns a random sentence*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.lorem.sentence(4) // 'Quickly up brace lung.'
-```
-
-
-
-### Lorem.word()
-
-```ts
-word(): string;
-```
-
-Generates a random word.
-
-*Returns a random word*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.lorem.word() // 'quickly'
-```
-
-
-
-### Lorem.question()
-
-```ts
-question(): string;
-```
-
-Generates a random question.
-
-*Returns a random question*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.lorem.question() // 'Forage pinterest direct trade pug skateboard food truck flannel cold-pressed?'
-```
-
-
-
-### Lorem.quote()
-
-```ts
-quote(): string;
-```
-
-Generates a random quote from a random person.
-
-*Returns a random quote from a random person*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.lorem.quote() // '"Forage pinterest direct trade pug skateboard food truck flannel cold-pressed." - Lukas Ledner'
-```
-
-
-
-PasswordOptions
----------------
-
-Options for password generation.
-
-### PasswordOptions.lower
-
-```ts
-readonly lower?: boolean;
-```
-
-Include lowercase letters.
-
-### PasswordOptions.upper
-
-```ts
-readonly upper?: boolean;
-```
-
-Include uppercase letters.
-
-### PasswordOptions.numeric
-
-```ts
-readonly numeric?: boolean;
-```
-
-Include a number
-
-### PasswordOptions.special
-
-```ts
-readonly special?: boolean;
-```
-
-Include a special character.
-
-### PasswordOptions.space
-
-```ts
-readonly space?: boolean;
-```
-
-Include a space.
-
-### PasswordOptions.length
-
-```ts
-readonly length?: int;
-```
-
-The length of the password.
-
-Internet
---------
-
-Generator to generate internet related entries.
-
-### Internet.domainName()
-
-```ts
-domainName(): string;
-```
-
-Generates a random url domain name.
-
-*Returns a random url domain name*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.internet.domainName() // 'internalenhance.org'
-```
-
-
-
-### Internet.domainSuffix()
-
-```ts
-domainSuffix(): string;
-```
-
-Generates a random domain suffix.
-
-*Returns a random domain suffix*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.internet.domainSuffix() // 'internalenhance.org'
-```
-
-
-
-### Internet.email()
-
-```ts
-email(): string;
-```
-
-Generates a random email address.
-
-*Returns a random email address*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.internet.email() // 'josiahthiel@luettgen.biz'
-```
-
-
-
-### Internet.emoji()
-
-```ts
-emoji(): string;
-```
-
-Generates a random emoji.
-
-*Returns a random emoji*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.internet.emoji() // '🐮'
-```
-
-
-
-### Internet.emojiAlias()
-
-```ts
-emojiAlias(): string;
-```
-
-Generates a random emoji alias.
-
-*Returns a random emoji alias*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.internet.emojiAlias() // 'slovakia'
-```
-
-
-
-### Internet.emojiCategory()
-
-```ts
-emojiCategory(): string;
-```
-
-Generates a random emoji category.
-
-*Returns a random emoji category*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.internet.emojiCategory() // 'Smileys & Emotion'
-```
-
-
-
-### Internet.emojiDescription()
-
-```ts
-emojiDescription(): string;
-```
-
-Generates a random emoji description.
-
-*Returns a random emoji description*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.internet.emojiDescription() // 'disguised face'
-```
-
-
-
-### Internet.emojiTag()
-
-```ts
-emojiTag(): string;
-```
-
-Generates a random emoji tag.
-
-*Returns a random emoji tag*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.internet.emojiTag() // 'lick'
-```
-
-
-
-### Internet.httpMethod()
-
-```ts
-httpMethod(): string;
-```
-
-Generates a random HTTP method.
-
-*Returns a random HTTP method*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.internet.httpMethod() // 'HEAD'
-```
-
-
-
-### Internet.httpStatusCode()
-
-```ts
-httpStatusCode(): int;
-```
-
-Generates a random HTTP status code.
-
-*Returns a random HTTP status code*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.internet.httpStatusCode() // 400
-```
-
-
-
-### Internet.httpVersion()
-
-```ts
-httpVersion(): string;
-```
-
-Generates a random HTTP version.
-
-*Returns a random HTTP version*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.internet.httpVersion() // 'HTTP/1.0'
-```
-
-
-
-### Internet.ipv4()
-
-```ts
-ipv4(): string;
-```
-
-Generates a random IPv4 address.
-
-*Returns a random IPv4 address*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.internet.ipv4() // '234.106.177.171'
-```
-
-
-
-### Internet.ipv6()
-
-```ts
-ipv6(): string;
-```
-
-Generates a random IPv6 address.
-
-*Returns a random IPv6 address*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.internet.ipv6() // '3aea:ef6a:38b1:7cab:7f0:946c:a3a9:cb90'
-```
-
-
-
-### Internet.mac()
-
-```ts
-mac(): string;
-```
-
-Generates a random mac address.
-
-*Returns a random mac address*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.internet.mac() // '87:2d:cd:bc:0d:f3'
-```
-
-
-
-### Internet.url()
-
-```ts
-url(): string;
-```
-
-Generates a random URL.
-
-*Returns a random URL*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.internet.url() // 'http://www.forwardtransition.biz/enhance/benchmark'
-```
-
-
-
-### Internet.userAgent()
-
-```ts
-userAgent(): string;
-```
-
-Generates a random browser user agent.
-
-*Returns a random browser user agent*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.internet.userAgent() // 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/5311 (KHTML, like Gecko) Chrome/37.0.834.0 Mobile Safari/5311'
-```
-
-
-
-### Internet.chromeUserAgent()
-
-```ts
-chromeUserAgent(): string;
-```
-
-Generates a random chrome browser user agent.
-
-*Returns a random chrome browser user agent*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.internet.chromeUserAgent() // 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/5340 (KHTML, like Gecko) Chrome/40.0.816.0 Mobile Safari/5340'
-```
-
-
-
-### Internet.firefoxUserAgent()
-
-```ts
-firefoxUserAgent(): string;
-```
-
-Generates a random firefox browser user agent.
-
-*Returns a random firefox browser user agent*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.internet.firefoxUserAgent() // 'Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_9_1 rv:5.0) Gecko/1979-07-30 Firefox/37.0'
-```
-
-
-
-### Internet.operaUserAgent()
-
-```ts
-operaUserAgent(): string;
-```
-
-Generates a random opera browser user agent.
-
-*Returns a random opera browser user agent*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.internet.operaUserAgent() // 'Opera/10.45 (X11; Linux i686; en-US) Presto/2.13.288 Version/13.00'
-```
-
-
-
-### Internet.safariUserAgent()
-
-```ts
-safariUserAgent(): string;
-```
-
-Generates a random safari browser user agent.
-
-*Returns a random safari browser user agent*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.internet.safariUserAgent() // 'Mozilla/5.0 (iPhone; CPU iPhone OS 7_3_2 like Mac OS X; en-US) AppleWebKit/534.34.8 (KHTML, like Gecko) Version/3.0.5 Mobile/8B114 Safari/6534.34.8'
-```
-
-
-
-### Internet.userName()
-
-```ts
-userName(): string;
-```
-
-Generates a random username.
-
-*Returns a random username*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.internet.userName() // 'Abshire5538'
-```
-
-
-
-### Internet.password()
-
-```ts
-password(): string;
-```
-
-Generates a random password.
-
-By default, the generated password will be 8 characters long and contain uppercase and lowercase letters, numbers and special characters.
-
-In the next API version, the function will handle the options parameter, which can be used to configure which characters should be included in the generated password.
-
-*Returns a random password*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.internet.password() // 'rAhz-A78'
-```
-
-
-
-### Internet.port()
-
-```ts
-port(): uint16;
-```
-
-Generates a random port number.
-
-*Returns a random port number*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.internet.port() // 15082
-```
-
-
-
-Currency
---------
-
-Currency properties.
-
-### Currency.code
-
-```ts
-readonly code: string;
-```
-
-Currency code.
-
-### Currency.name
-
-```ts
-readonly name: string;
-```
-
-Currency name.
-
-Finance
--------
-
-Generator to generate finance and money related entries.
-
-### Finance.accountNumber()
-
-```ts
-accountNumber(): string;
-```
-
-Generates a random 12 digit account number.
-
-*Returns a random account number*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.finance.accountNumber() // '805388385166'
-```
-
-
-
-### Finance.bitcoinAddress()
-
-```ts
-bitcoinAddress(): string;
-```
-
-Generates a random Bitcoin address.
-
-*Returns a random Bitcoin address*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.finance.bitcoinAddress() // '1t1xAUWhqY1QsZFAlYm6Z75zxerJ'
-```
-
-
-
-### Finance.creditCardCVV()
-
-```ts
-creditCardCVV(): string;
-```
-
-Generates a random credit card CVV.
-
-*Returns a random credit card CVV*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.finance.creditCardCVV() // '405'
-```
-
-
-
-### Finance.creditCardNumber()
-
-```ts
-creditCardNumber(): string;
-```
-
-Generates a random credit card number.
-
-*Returns a random credit card number*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.finance.creditCardNumber() // '5553883851665702'
-```
-
-
-
-### Finance.currency()
-
-```ts
-currency(): Currency;
-```
-
-Returns a random currency object, containing `code` and `name` properties.
-
-*Returns a random currency object*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.finance.currency() // {code:"VEF", name:"Venezuela Bolivar"}
-```
-
-
-
-### Finance.currencyCode()
-
-```ts
-currencyCode(): string;
-```
-
-Returns a random currency code. (The short text/abbreviation for the currency)
-
-*Returns a random currency code*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.finance.currencyCode() // 'VEF'
-```
-
-
-
-### Finance.currencyName()
-
-```ts
-currencyName(): string;
-```
-
-Returns a random currency name.
-
-*Returns a random currency name*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.finance.currencyName() // 'Venezuela Bolivar'
-```
-
-
-
-### Finance.pin()
-
-```ts
-pin(): string;
-```
-
-Generates a random PIN number.
-
-By default, the generated PIN will be 4 digits long.
-
-In the next API version, the function will handle the options parameter, which can be used to configure the number of digits.
-
-*Returns a random PIN number*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.finance.pin() // '0053'
-```
-
-
-
-### Finance.routing()
-
-```ts
-routing(): string;
-```
-
-Generates a random 9 digit routing number.
-
-*Returns a random routing number*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.finance.routing() // '605388385'
-```
-
-
-
-Phone
------
-
-Generator to generate phone-related data.
-
-### Phone.number()
-
-```ts
-number(): string;
-```
-
-Generates a random phone number.
-
-*Returns a random phone number*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.phone.number() // '605388385'
-```
-
-
-
-### Phone.numberFormatted()
-
-```ts
-numberFormatted(): string;
-```
-
-Generates a random formatted phone number.
-
-*Returns a random formatted phone number*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.phone.numberFormatted() // '1-053-883-8516'
-```
-
-
-
-Vehicle
--------
-
-Generator to generate vehicle related entries.
-
-### Vehicle.fuel()
-
-```ts
-fuel(): string;
-```
-
-Generates a random fuel type.
-
-*Returns a random fuel type*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.vehicle.number() // 'Ethanol'
-```
-
-
-
-### Vehicle.manufacturer()
-
-```ts
-manufacturer(): string;
-```
-
-Generates a random manufacturer name.
-
-*Returns a random manufacturer name*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.vehicle.manufacturer() // 'Lancia'
-```
-
-
-
-### Vehicle.model()
-
-```ts
-model(): string;
-```
-
-Generates a random vehicle model.
-
-*Returns a random vehicle model*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.vehicle.model() // 'Tucson 4wd'
-```
-
-
-
-### Vehicle.type()
-
-```ts
-type(): string;
-```
-
-Generates a random vehicle type.
-
-*Returns a random vehicle type*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.vehicle.type() // 'Passenger car compact'
-```
-
-
-
-### Vehicle.transmission()
-
-```ts
-transmission(): string;
-```
-
-Generates a random transmission type.
-
-*Returns a random transmission type*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.vehicle.transmission() // 'Manual'
-```
-
-
-
-Color
------
-
-Generator to generate colors.
-
-### Color.human()
-
-```ts
-human(): string;
-```
-
-Generates a random human-readable color name.
-
-*Returns a random human-readable color name*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.color.human() // 'black'
-```
-
-
-
-### Color.rgb()
-
-```ts
-rgb(): string;
-```
-
-Generates a random RGB color.
-
-*Returns a random RGB color*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.color.rgb() // '#bd38ac'
-```
-
-
-
-Location
---------
-
-Generator to generate addresses and locations.
-
-### Location.country()
-
-```ts
-country(): string;
-```
-
-Generates a random country name.
-
-*Returns a random country name*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.location.country() // 'Togo'
-```
-
-
-
-### Location.countryCode()
-
-```ts
-countryCode(): string;
-```
-
-Generates a random country code.
-
-*Returns a random country code*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.location.countryCode() // 'TG'
-```
-
-
-
-### Location.zipCode()
-
-```ts
-zipCode(): string;
-```
-
-Generates a random zip code.
-
-*Returns a random zip code*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.location.zipCode() // '25388'
-```
-
-
-
-### Location.state()
-
-```ts
-state(): string;
-```
-
-Generates a random state name.
-
-*Returns a random state name*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.location.state() // 'Massachusetts'
-```
-
-
-
-### Location.stateAbbr()
-
-```ts
-stateAbbr(): string;
-```
-
-Generates a random state abbreviated name.
-
-*Returns a random state abbreviated name*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.location.stateAbbr() // 'AA'
-```
-
-
-
-### Location.city()
-
-```ts
-city(): string;
-```
-
-Generates a random city name.
-
-*Returns a random city name*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.location.city() // 'Hialeah'
-```
-
-
-
-### Location.street()
-
-```ts
-street(): string;
-```
-
-Generates a random street name.
-
-*Returns a random street name*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.location.street() // 'Fall'
-```
-
-
-
-### Location.buildingNumber()
-
-```ts
-buildingNumber(): string;
-```
-
-Generates a random building number.
-
-*Returns a random building number*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.location.buildingNumber() // '25388'
-```
-
-
-
-### Location.timeZone()
-
-```ts
-timeZone(): string;
-```
-
-Generates a random time zone.
-
-*Returns a random time zone*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.location.timeZone() // 'Tonga Standard Time'
-```
-
-
-
-### Location.latitude()
-
-```ts
-latitude(): number;
-```
-
-Generates a random latitude.
-
-*Returns a random latitude*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.location.latitude() // 11.394086
-```
-
-
-
-### Location.longitude()
-
-```ts
-longitude(): number;
-```
-
-Generates a random longitude.
-
-*Returns a random longitude*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.location.longitude() // 22.788172
-```
-
-
-
-DateTime
---------
-
-Generator to generate dates and times.
-
-### DateTime.anytime()
-
-```ts
-anytime(): Date;
-```
-
-Generates a random Date.
-
-*Returns a random Date*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.datetime.anytime() //
-```
-
-
-
-### DateTime.future()
-
-```ts
-future(): Date;
-```
-
-Generates a random future Date.
-
-*Returns a random future Date*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.datetime.future() //
-```
-
-
-
-### DateTime.past()
-
-```ts
-past(): Date;
-```
-
-Generates a random past Date.
-
-*Returns a random past Date*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.datetime.past() //
-```
-
-
-
-### DateTime.weekday()
-
-```ts
-weekday(): string;
-```
-
-Generates a random weekday.
-
-*Returns a random weekday*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.datetime.weekday() // 'Sunday'
-```
-
-
-
-### DateTime.timeZone()
-
-```ts
-timeZone(): string;
-```
-
-Generates a random time zone.
-
-*Returns a random time zone*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.datetime.timeZone() // 'Tonga Standard Time'
-```
-
-
-
-### DateTime.timeZoneAbbr()
-
-```ts
-timeZoneAbbr(): string;
-```
-
-Generates a random time zone abbreviation.
-
-*Returns a random time zone abbreviation*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.datetime.timeZoneAbbr() // 'TST'
-```
-
-
-
-### DateTime.timeZoneRegion()
-
-```ts
-timeZoneRegion(): string;
-```
-
-Generates a random region style timezone.
-
-*Returns a random region style timezone*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.datetime.timeZoneRegion() // 'Asia/Manila'
-```
-
-
-
-### DateTime.monthString()
-
-```ts
-monthString(): string;
-```
-
-Generates a random month name.
-
-*Returns a random month name*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.datetime.monthString() // 'October'
-```
-
-
-
-### DateTime.nanoSecond()
-
-```ts
-nanoSecond(): int;
-```
-
-Generates a random nano second.
-
-*Returns a random nano second*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.datetime.nanoSecond() // 953698829
-```
-
-
-
-### DateTime.second()
-
-```ts
-second(): int;
-```
-
-Generates a random second.
-
-*Returns a random second*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.datetime.second() // 9
-```
-
-
-
-### DateTime.minute()
-
-```ts
-minute(): int;
-```
-
-Generates a random minute.
-
-*Returns a random minute*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.datetime.minute() // 9
-```
-
-
-
-### DateTime.hour()
-
-```ts
-hour(): int;
-```
-
-Generates a random hour.
-
-*Returns a random hour*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.datetime.hour() // 21
-```
-
-
-
-### DateTime.month()
-
-```ts
-month(): int;
-```
-
-Generates a random month.
-
-*Returns a random month*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.datetime.month() // 10
-```
-
-
-
-### DateTime.day()
-
-```ts
-day(): int;
-```
-
-Generates a random day.
-
-*Returns a random day*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.datetime.day() // 22
-```
-
-
-
-### DateTime.year()
-
-```ts
-year(): int;
-```
-
-Generates a random year.
-
-*Returns a random year*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.datetime.year() // 1979
-```
-
-
-
-Numbers
--------
-
-Generator to generate numbers of any kind.
-
-### Numbers.int()
-
-```ts
-int(): int64;
-```
-
-Generates a random integer number.
-
-In the next API version, it will be possible to set the lower and upper limits of the generation in an optional argument object.
-
-*Returns a random integer number*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.numbers.int() // 2131652109
-```
-
-
-
-### Numbers.float()
-
-```ts
-float(): float64;
-```
-
-Generates a random floating-point number.
-
-In the next API version, it will be possible to set the lower and upper limits of the generation in an optional argument object.
-
-*Returns a random floating-point number*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.numbers.float() // 1.012641406418422e308
-```
-
-
-
-Strings
--------
-
-Generator to generate string related entries.
-
-### Strings.letter()
-
-```ts
-letter(): string;
-```
-
-Generates a random letter.
-
-*Returns a random letter*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.strings.letter() // 'W'
-```
-
-
-
-### Strings.digit()
-
-```ts
-digit(): string;
-```
-
-Generates a random digit.
-
-*Returns a random digit*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.strings.digit() // '0'
-```
-
-
-
-### Strings.uuid()
-
-```ts
-uuid(): string;
-```
-
-Generates a random UUID (version 4, unique identifier based upon random numbers).
-
-*Returns a random UUID*
-
-Example
-
-```ts
-const faker = new Faker(11)
-
-faker.strings.uuid() // 'ea6ab1ab-f06c-4990-835d-e628b7e659e1'
-```
-
-
-
-Helpers
--------
-
-Various helper methods.
-
-### Helpers.numerify()
-
-```ts
-numerify(str: string): string;
-```
-
-### Helpers.lexify()
-
-```ts
-lexify(str: string): string;
-```
diff --git a/faker_bindings.go b/faker_bindings.go
index 172d6a7..fc4a71a 100644
--- a/faker_bindings.go
+++ b/faker_bindings.go
@@ -5778,9 +5778,15 @@ func goStringsToObject(v goStrings, vm *goja.Runtime) *goja.Object {
// Various helper methods.
type jsHelpers interface {
// numerifyMethod is the go binding for the JavaScript numerify method.
+ //
+ // TSDoc:
+ // Replaces '#' characters with random generated digits.
numerifyMethod(call goja.FunctionCall, vm *goja.Runtime) goja.Value
// lexifyMethod is the go binding for the JavaScript lexify method.
+ //
+ // TSDoc:
+ // Replaces '?' characters with random generated letters.
lexifyMethod(call goja.FunctionCall, vm *goja.Runtime) goja.Value
}
@@ -5790,9 +5796,15 @@ type jsHelpers interface {
// Various helper methods.
type goHelpers interface {
// numerifyMethod is the go representation of the numerify method.
+ //
+ // TSDoc:
+ // Replaces '#' characters with random generated digits.
numerifyMethod(strArg string) (string, error)
// lexifyMethod is the go representation of the lexify method.
+ //
+ // TSDoc:
+ // Replaces '?' characters with random generated letters.
lexifyMethod(strArg string) (string, error)
}
diff --git a/index.d.ts b/index.d.ts
index e63f1b1..a1caa8b 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -45,6 +45,7 @@
* }
* ```
*
+ * @module faker
*/
export as namespace faker;
diff --git a/module.go b/module.go
index 8f3392c..71d39cd 100644
--- a/module.go
+++ b/module.go
@@ -12,7 +12,6 @@ import (
)
//go:generate tygor --skeleton index.d.ts
-//go:generate tygor doc --output README.md index.d.ts
func init() {
register(newModule)
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644
index 0000000..5ac93f4
--- /dev/null
+++ b/tsconfig.json
@@ -0,0 +1,23 @@
+{
+ "typedocOptions": {
+ "entryPoints": ["./index.d.ts"],
+ "out": "build/docs",
+ "name": "xk6-faker",
+ "readme": "none",
+ "hideGenerator": true,
+ "disableSources": true,
+ "navigation": {
+ "includeCategories": false,
+ "includeGroups": false,
+ "includeFolders": false
+ },
+ "categorizeByGroup": false,
+ "visibilityFilters": {},
+ "navigationLinks": {
+ "GitHub": "https://github.com/szkiba/xk6-faker"
+ },
+ "sidebarLinks": {
+ "Example": "http://example.com"
+ }
+ }
+}