aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorST-DDT <[email protected]>2022-02-20 18:51:48 +0100
committerGitHub <[email protected]>2022-02-20 18:51:48 +0100
commitb22cf3b809efab92f5933b9f6641e1959a4c8fcc (patch)
tree7e71f5f90121afc3c2420a561f7370d8213cf8c7 /src
parentf7899fde7f8b70db47614168532d3c3606423661 (diff)
downloadfaker-b22cf3b809efab92f5933b9f6641e1959a4c8fcc.tar.xz
faker-b22cf3b809efab92f5933b9f6641e1959a4c8fcc.zip
docs: various fixes (#523)
Diffstat (limited to 'src')
-rw-r--r--src/datatype.ts5
-rw-r--r--src/date.ts10
-rw-r--r--src/finance.ts7
-rw-r--r--src/helpers.ts20
-rw-r--r--src/image.ts90
-rw-r--r--src/index.ts2
-rw-r--r--src/internet.ts4
-rw-r--r--src/lorem.ts2
-rw-r--r--src/mersenne.ts2
-rw-r--r--src/name.ts2
-rw-r--r--src/phone.ts5
-rw-r--r--src/random.ts2
-rw-r--r--src/time.ts5
-rw-r--r--src/word.ts3
14 files changed, 90 insertions, 69 deletions
diff --git a/src/datatype.ts b/src/datatype.ts
index 2fbc5c6b..8803f8bc 100644
--- a/src/datatype.ts
+++ b/src/datatype.ts
@@ -1,5 +1,8 @@
import type { Faker } from '.';
+/**
+ * Module to generate various primitive values and data types.
+ */
export class Datatype {
constructor(private readonly faker: Faker, seed?: any[] | any) {
// Use a user provided seed if it is an array or number
@@ -139,7 +142,7 @@ export class Datatype {
}
/**
- * Returns a string containing UTF-16 chars between 33 and 125 ('!' to '}').
+ * Returns a string containing UTF-16 chars between 33 and 125 (`!` to `}`).
*
* @param length Length of the generated string. Max length is `2^20`. Defaults to `10`.
*
diff --git a/src/date.ts b/src/date.ts
index 97b54b73..a8b95bb8 100644
--- a/src/date.ts
+++ b/src/date.ts
@@ -99,7 +99,7 @@ export class _Date {
*
* @param from The early date boundary.
* @param to The late date boundary.
- * @param num The number of dates to generate. Defaults to 3.
+ * @param num The number of dates to generate. Defaults to `3`.
*
* @example
* faker.date.betweens('2020-01-01T00:00:00.000Z', '2030-01-01T00:00:00.000Z')
@@ -195,8 +195,8 @@ export class _Date {
* Returns a random name of a month.
*
* @param options The optional options to use.
- * @param options.abbr Whether to return an abbreviation. Defaults to false.
- * @param options.context Whether to return the name of a month in a context. Defaults to false.
+ * @param options.abbr Whether to return an abbreviation. Defaults to `false`.
+ * @param options.context Whether to return the name of a month in a context. Defaults to `false`.
*
* @example
* faker.date.month() // 'October'
@@ -228,8 +228,8 @@ export class _Date {
* Returns a random day of the week.
*
* @param options The optional options to use.
- * @param options.abbr Whether to return an abbreviation. Defaults to false.
- * @param options.context Whether to return the day of the week in a context. Defaults to false.
+ * @param options.abbr Whether to return an abbreviation. Defaults to `false`.
+ * @param options.context Whether to return the day of the week in a context. Defaults to `false`.
*
* @example
* faker.date.weekday() // 'Monday'
diff --git a/src/finance.ts b/src/finance.ts
index 35fd9d87..bf1f725f 100644
--- a/src/finance.ts
+++ b/src/finance.ts
@@ -24,7 +24,7 @@ export class Finance {
/**
* Generates a random account number.
*
- * @param length The length of the account number. Defaults to 8.
+ * @param length The length of the account number. Defaults to `8`.
*
* @example
* faker.finance.account() // 92842238
@@ -113,9 +113,6 @@ export class Finance {
return template;
}
- // min and max take in minimum and maximum amounts, dec is the decimal place you want rounded to, symbol is $, €, £, etc
- // NOTE: this returns a string representation of the value, if you want a number use parseFloat and no symbol
-
/**
* Generates a random amount between the given bounds (inclusive).
*
@@ -256,7 +253,7 @@ export class Finance {
*
* @example
* faker.finance.creditCardNumber() // '4427163488668'
- * faker.finance.creditCardNumber('Visa') // '4882664999003'
+ * faker.finance.creditCardNumber('visa') // '4882664999003'
* faker.finance.creditCardNumber('63[7-9]#-####-####-###L') // '6375-3265-4676-6644'
*/
creditCardNumber(provider = ''): string {
diff --git a/src/helpers.ts b/src/helpers.ts
index 0bb6b4d0..31878c64 100644
--- a/src/helpers.ts
+++ b/src/helpers.ts
@@ -110,6 +110,9 @@ export interface Transaction {
account: string;
}
+/**
+ * Module with various helper methods that don't fit in a particular category.
+ */
export class Helpers {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
@@ -128,6 +131,8 @@ export class Helpers {
*
* @param array The array to select an element from.
*
+ * @see faker.random.arrayElement()
+ *
* @example
* faker.helpers.randomize() // 'c'
* faker.helpers.randomize([1, 2, 3]) // '2'
@@ -298,7 +303,7 @@ export class Helpers {
/**
* Repeats the given string the given number of times.
*
- * @param string The string to repeat.
+ * @param string The string to repeat. Defaults to `''`.
* @param num The number of times to repeat it. Defaults to `0`.
*
* @example
@@ -421,9 +426,10 @@ export class Helpers {
* @param source The strings to choose from or a function that generates a string.
* @param length The number of elements to generate.
*
- * @example uniqueArray(faker.random.word, 50)
- * @example uniqueArray(faker.definitions.name.first_name, 6)
- * @example uniqueArray(["Hello", "World", "Goodbye"], 2)
+ * @example
+ * uniqueArray(faker.random.word, 50)
+ * uniqueArray(faker.definitions.name.first_name, 6)
+ * uniqueArray(["Hello", "World", "Goodbye"], 2)
*/
uniqueArray<T>(source: T[] | (() => T), length: number): T[] {
if (Array.isArray(source)) {
@@ -452,6 +458,12 @@ export class Helpers {
* @param data The data used to populate the placeholders.
* This is a record where the key is the template placeholder,
* whereas the value is either a string or a function suitable for `String.replace()`.
+ *
+ * @example
+ * faker.helpers.mustache('I found {{count}} instances of "{{word}}".', {
+ * count: () => `${faker.datatype.number()}`,
+ * word: "this word",
+ * }) // 'I found 57591 instances of "this word".'
*/
mustache(
str: string | undefined,
diff --git a/src/image.ts b/src/image.ts
index 571bc6f8..72cceb12 100644
--- a/src/image.ts
+++ b/src/image.ts
@@ -30,9 +30,9 @@ export class Image {
/**
* Generates a random image url from one of the supported categories.
*
- * @param width The width of the image.
- * @param height The height of the image.
- * @param randomize Whether to randomize the image or not.
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
* faker.image.image() // 'http://placeimg.com/640/480/city'
@@ -79,7 +79,7 @@ export class Image {
* @param width The width of the image. Defaults to `640`.
* @param height The height of the image. Defaults to `480`.
* @param category The category of the image. By default, a random one will be selected.
- * @param randomize Whether to randomize the image or not.
+ * @param randomize Whether to randomize the image or not. Defaults to `false`.
* @param https When true, return a `https` url. Otherwise, return a `http` url.
*
* @example
@@ -117,9 +117,9 @@ export class Image {
/**
* Generates a random abstract image url.
*
- * @param width The width of the image.
- * @param height The height of the image.
- * @param randomize Whether to randomize the image or not.
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
* faker.image.abstract() // 'http://placeimg.com/640/480/abstract'
@@ -133,9 +133,9 @@ export class Image {
/**
* Generates a random animal image url.
*
- * @param width The width of the image.
- * @param height The height of the image.
- * @param randomize Whether to randomize the image or not.
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
* faker.image.animals() // 'http://placeimg.com/640/480/animals'
@@ -149,9 +149,9 @@ export class Image {
/**
* Generates a random business image url.
*
- * @param width The width of the image.
- * @param height The height of the image.
- * @param randomize Whether to randomize the image or not.
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
* faker.image.business() // 'http://placeimg.com/640/480/business'
@@ -165,9 +165,9 @@ export class Image {
/**
* Generates a random cat image url.
*
- * @param width The width of the image.
- * @param height The height of the image.
- * @param randomize Whether to randomize the image or not.
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
* faker.image.cats() // 'http://placeimg.com/640/480/cats'
@@ -181,9 +181,9 @@ export class Image {
/**
* Generates a random city image url.
*
- * @param width The width of the image.
- * @param height The height of the image.
- * @param randomize Whether to randomize the image or not.
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
* faker.image.city() // 'http://placeimg.com/640/480/city'
@@ -197,9 +197,9 @@ export class Image {
/**
* Generates a random food image url.
*
- * @param width The width of the image.
- * @param height The height of the image.
- * @param randomize Whether to randomize the image or not.
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
* faker.image.food() // 'http://placeimg.com/640/480/food'
@@ -213,9 +213,9 @@ export class Image {
/**
* Generates a random nightlife image url.
*
- * @param width The width of the image.
- * @param height The height of the image.
- * @param randomize Whether to randomize the image or not.
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
* faker.image.nightlife() // 'http://placeimg.com/640/480/nightlife'
@@ -229,9 +229,9 @@ export class Image {
/**
* Generates a random fashion image url.
*
- * @param width The width of the image.
- * @param height The height of the image.
- * @param randomize Whether to randomize the image or not.
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
* faker.image.fashion() // 'http://placeimg.com/640/480/fashion'
@@ -245,9 +245,9 @@ export class Image {
/**
* Generates a random people image url.
*
- * @param width The width of the image.
- * @param height The height of the image.
- * @param randomize Whether to randomize the image or not.
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
* faker.image.people() // 'http://placeimg.com/640/480/people'
@@ -261,9 +261,9 @@ export class Image {
/**
* Generates a random nature image url.
*
- * @param width The width of the image.
- * @param height The height of the image.
- * @param randomize Whether to randomize the image or not.
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
* faker.image.nature() // 'http://placeimg.com/640/480/nature'
@@ -277,9 +277,9 @@ export class Image {
/**
* Generates a random sports image url.
*
- * @param width The width of the image.
- * @param height The height of the image.
- * @param randomize Whether to randomize the image or not.
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
* faker.image.sports() // 'http://placeimg.com/640/480/sports'
@@ -293,9 +293,9 @@ export class Image {
/**
* Generates a random technics image url.
*
- * @param width The width of the image.
- * @param height The height of the image.
- * @param randomize Whether to randomize the image or not.
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
* faker.image.technics() // 'http://placeimg.com/640/480/technics'
@@ -309,9 +309,9 @@ export class Image {
/**
* Generates a random transport image url.
*
- * @param width The width of the image.
- * @param height The height of the image.
- * @param randomize Whether to randomize the image or not.
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
+ * @param randomize Whether to randomize the image or not. Defaults to `false`.
*
* @example
* faker.image.transport() // 'http://placeimg.com/640/480/transport'
@@ -325,8 +325,8 @@ export class Image {
/**
* Generates a random data uri containing an svg image.
*
- * @param width The width of the image.
- * @param height The height of the image.
+ * @param width The width of the image. Defaults to `640`.
+ * @param height The height of the image. Defaults to `480`.
* @param color The color to use. Defaults to `grey`.
*
* @example
diff --git a/src/index.ts b/src/index.ts
index 091eed91..2b6f3582 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -162,7 +162,7 @@ export class Faker {
/**
* Set Faker's locale
*
- * @param locale
+ * @param locale The locale to set (e.g. `en` or `en_AU`, `en_AU_ocker`).
*/
setLocale(locale: UsableLocale): void {
this.locale = locale;
diff --git a/src/internet.ts b/src/internet.ts
index 995f62b0..5e253c47 100644
--- a/src/internet.ts
+++ b/src/internet.ts
@@ -319,7 +319,7 @@ export class Internet {
/**
* Generates a random mac address.
*
- * @param sep The optional separator to use. Can be either `':'`, `'-'` or `''`. Defaults to `':'`
+ * @param sep The optional separator to use. Can be either `':'`, `'-'` or `''`. Defaults to `':'`.
*
* @example
* faker.internet.mac() // '32:8e:2e:09:c6:05'
@@ -350,7 +350,7 @@ export class Internet {
* @param len The length of the password to generate. Defaults to `15`.
* @param memorable Whether the generated password should be memorable. Defaults to `false`.
* @param pattern The pattern that all chars should match should match. Defaults to `/\w/`.
- * @param prefix The prefix to use. Defaults to `''`
+ * @param prefix The prefix to use. Defaults to `''`.
*
* @example
* faker.internet.password() // '89G1wJuBLbGziIs'
diff --git a/src/lorem.ts b/src/lorem.ts
index f682632b..2c22ac10 100644
--- a/src/lorem.ts
+++ b/src/lorem.ts
@@ -22,7 +22,7 @@ export class Lorem {
/**
* Generates a word of a specified length.
*
- * @param length length of the word that should be returned. Defaults to a random length
+ * @param length length of the word that should be returned. Defaults to a random length.
*
* @example
* faker.lorem.word() // 'temporibus'
diff --git a/src/mersenne.ts b/src/mersenne.ts
index e9750f8e..34c0c842 100644
--- a/src/mersenne.ts
+++ b/src/mersenne.ts
@@ -19,7 +19,7 @@ export class Mersenne {
}
/**
- * Generates a random number between [min, max)'.
+ * Generates a random number between `[min, max)`.
*
* @param max The maximum number. Defaults to `0`.
* @param min The minimum number. Defaults to `32768`. Required if `max` is set.
diff --git a/src/name.ts b/src/name.ts
index 663ae748..6b727569 100644
--- a/src/name.ts
+++ b/src/name.ts
@@ -216,7 +216,7 @@ export class Name {
/**
* Return a random gender.
*
- * @param binary Whether to return only binary gender names. Defaults to false.
+ * @param binary Whether to return only binary gender names. Defaults to `false`.
*
* @example
* faker.name.gender() // 'Trans*Man'
diff --git a/src/phone.ts b/src/phone.ts
index 4319f9b6..88b2a038 100644
--- a/src/phone.ts
+++ b/src/phone.ts
@@ -1,5 +1,8 @@
import type { Faker } from '.';
+/**
+ * Module to generate phone numbers.
+ */
export class Phone {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly
@@ -14,7 +17,7 @@ export class Phone {
/**
* Generates a random phone number.
*
- * @param format Format of the phone number. Defaults to `faker.phone.phoneFormats()`
+ * @param format Format of the phone number. Defaults to `faker.phone.phoneFormats()`.
*
* @example
* faker.phone.phoneNumber() // '961-770-7727'
diff --git a/src/random.ts b/src/random.ts
index 28abb3c2..914e7c2b 100644
--- a/src/random.ts
+++ b/src/random.ts
@@ -262,7 +262,7 @@ export class Random {
/**
* Returns string with set of random words.
*
- * @param count Number of words. Defaults to a random value between `1` and `3`
+ * @param count Number of words. Defaults to a random value between `1` and `3`.
*
* @example
* faker.random.words() // 'neural'
diff --git a/src/time.ts b/src/time.ts
index cae55621..df9c0c71 100644
--- a/src/time.ts
+++ b/src/time.ts
@@ -1,6 +1,9 @@
+/**
+ * Module to generate time of dates in various formats.
+ */
export class Time {
/**
- * Returns recent time
+ * Returns recent time.
*
* @param format 'abbr' || 'wide' || 'unix' (default)
*
diff --git a/src/word.ts b/src/word.ts
index b91c1356..482db788 100644
--- a/src/word.ts
+++ b/src/word.ts
@@ -1,5 +1,8 @@
import type { Faker } from '.';
+/**
+ * Module to return various types of words.
+ */
export class Word {
constructor(private readonly faker: Faker) {
// Bind `this` so namespaced is working correctly