Skip to content

Commit b22cf3b

Browse files
authored
docs: various fixes (#523)
1 parent f7899fd commit b22cf3b

14 files changed

+90
-69
lines changed

src/datatype.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import type { Faker } from '.';
22

3+
/**
4+
* Module to generate various primitive values and data types.
5+
*/
36
export class Datatype {
47
constructor(private readonly faker: Faker, seed?: any[] | any) {
58
// Use a user provided seed if it is an array or number
@@ -139,7 +142,7 @@ export class Datatype {
139142
}
140143

141144
/**
142-
* Returns a string containing UTF-16 chars between 33 and 125 ('!' to '}').
145+
* Returns a string containing UTF-16 chars between 33 and 125 (`!` to `}`).
143146
*
144147
* @param length Length of the generated string. Max length is `2^20`. Defaults to `10`.
145148
*

src/date.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export class _Date {
9999
*
100100
* @param from The early date boundary.
101101
* @param to The late date boundary.
102-
* @param num The number of dates to generate. Defaults to 3.
102+
* @param num The number of dates to generate. Defaults to `3`.
103103
*
104104
* @example
105105
* faker.date.betweens('2020-01-01T00:00:00.000Z', '2030-01-01T00:00:00.000Z')
@@ -195,8 +195,8 @@ export class _Date {
195195
* Returns a random name of a month.
196196
*
197197
* @param options The optional options to use.
198-
* @param options.abbr Whether to return an abbreviation. Defaults to false.
199-
* @param options.context Whether to return the name of a month in a context. Defaults to false.
198+
* @param options.abbr Whether to return an abbreviation. Defaults to `false`.
199+
* @param options.context Whether to return the name of a month in a context. Defaults to `false`.
200200
*
201201
* @example
202202
* faker.date.month() // 'October'
@@ -228,8 +228,8 @@ export class _Date {
228228
* Returns a random day of the week.
229229
*
230230
* @param options The optional options to use.
231-
* @param options.abbr Whether to return an abbreviation. Defaults to false.
232-
* @param options.context Whether to return the day of the week in a context. Defaults to false.
231+
* @param options.abbr Whether to return an abbreviation. Defaults to `false`.
232+
* @param options.context Whether to return the day of the week in a context. Defaults to `false`.
233233
*
234234
* @example
235235
* faker.date.weekday() // 'Monday'

src/finance.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class Finance {
2424
/**
2525
* Generates a random account number.
2626
*
27-
* @param length The length of the account number. Defaults to 8.
27+
* @param length The length of the account number. Defaults to `8`.
2828
*
2929
* @example
3030
* faker.finance.account() // 92842238
@@ -113,9 +113,6 @@ export class Finance {
113113
return template;
114114
}
115115

116-
// min and max take in minimum and maximum amounts, dec is the decimal place you want rounded to, symbol is $, €, £, etc
117-
// NOTE: this returns a string representation of the value, if you want a number use parseFloat and no symbol
118-
119116
/**
120117
* Generates a random amount between the given bounds (inclusive).
121118
*
@@ -256,7 +253,7 @@ export class Finance {
256253
*
257254
* @example
258255
* faker.finance.creditCardNumber() // '4427163488668'
259-
* faker.finance.creditCardNumber('Visa') // '4882664999003'
256+
* faker.finance.creditCardNumber('visa') // '4882664999003'
260257
* faker.finance.creditCardNumber('63[7-9]#-####-####-###L') // '6375-3265-4676-6644'
261258
*/
262259
creditCardNumber(provider = ''): string {

src/helpers.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ export interface Transaction {
110110
account: string;
111111
}
112112

113+
/**
114+
* Module with various helper methods that don't fit in a particular category.
115+
*/
113116
export class Helpers {
114117
constructor(private readonly faker: Faker) {
115118
// Bind `this` so namespaced is working correctly
@@ -128,6 +131,8 @@ export class Helpers {
128131
*
129132
* @param array The array to select an element from.
130133
*
134+
* @see faker.random.arrayElement()
135+
*
131136
* @example
132137
* faker.helpers.randomize() // 'c'
133138
* faker.helpers.randomize([1, 2, 3]) // '2'
@@ -298,7 +303,7 @@ export class Helpers {
298303
/**
299304
* Repeats the given string the given number of times.
300305
*
301-
* @param string The string to repeat.
306+
* @param string The string to repeat. Defaults to `''`.
302307
* @param num The number of times to repeat it. Defaults to `0`.
303308
*
304309
* @example
@@ -421,9 +426,10 @@ export class Helpers {
421426
* @param source The strings to choose from or a function that generates a string.
422427
* @param length The number of elements to generate.
423428
*
424-
* @example uniqueArray(faker.random.word, 50)
425-
* @example uniqueArray(faker.definitions.name.first_name, 6)
426-
* @example uniqueArray(["Hello", "World", "Goodbye"], 2)
429+
* @example
430+
* uniqueArray(faker.random.word, 50)
431+
* uniqueArray(faker.definitions.name.first_name, 6)
432+
* uniqueArray(["Hello", "World", "Goodbye"], 2)
427433
*/
428434
uniqueArray<T>(source: T[] | (() => T), length: number): T[] {
429435
if (Array.isArray(source)) {
@@ -452,6 +458,12 @@ export class Helpers {
452458
* @param data The data used to populate the placeholders.
453459
* This is a record where the key is the template placeholder,
454460
* whereas the value is either a string or a function suitable for `String.replace()`.
461+
*
462+
* @example
463+
* faker.helpers.mustache('I found {{count}} instances of "{{word}}".', {
464+
* count: () => `${faker.datatype.number()}`,
465+
* word: "this word",
466+
* }) // 'I found 57591 instances of "this word".'
455467
*/
456468
mustache(
457469
str: string | undefined,

src/image.ts

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ export class Image {
3030
/**
3131
* Generates a random image url from one of the supported categories.
3232
*
33-
* @param width The width of the image.
34-
* @param height The height of the image.
35-
* @param randomize Whether to randomize the image or not.
33+
* @param width The width of the image. Defaults to `640`.
34+
* @param height The height of the image. Defaults to `480`.
35+
* @param randomize Whether to randomize the image or not. Defaults to `false`.
3636
*
3737
* @example
3838
* faker.image.image() // 'http://placeimg.com/640/480/city'
@@ -79,7 +79,7 @@ export class Image {
7979
* @param width The width of the image. Defaults to `640`.
8080
* @param height The height of the image. Defaults to `480`.
8181
* @param category The category of the image. By default, a random one will be selected.
82-
* @param randomize Whether to randomize the image or not.
82+
* @param randomize Whether to randomize the image or not. Defaults to `false`.
8383
* @param https When true, return a `https` url. Otherwise, return a `http` url.
8484
*
8585
* @example
@@ -117,9 +117,9 @@ export class Image {
117117
/**
118118
* Generates a random abstract image url.
119119
*
120-
* @param width The width of the image.
121-
* @param height The height of the image.
122-
* @param randomize Whether to randomize the image or not.
120+
* @param width The width of the image. Defaults to `640`.
121+
* @param height The height of the image. Defaults to `480`.
122+
* @param randomize Whether to randomize the image or not. Defaults to `false`.
123123
*
124124
* @example
125125
* faker.image.abstract() // 'http://placeimg.com/640/480/abstract'
@@ -133,9 +133,9 @@ export class Image {
133133
/**
134134
* Generates a random animal image url.
135135
*
136-
* @param width The width of the image.
137-
* @param height The height of the image.
138-
* @param randomize Whether to randomize the image or not.
136+
* @param width The width of the image. Defaults to `640`.
137+
* @param height The height of the image. Defaults to `480`.
138+
* @param randomize Whether to randomize the image or not. Defaults to `false`.
139139
*
140140
* @example
141141
* faker.image.animals() // 'http://placeimg.com/640/480/animals'
@@ -149,9 +149,9 @@ export class Image {
149149
/**
150150
* Generates a random business image url.
151151
*
152-
* @param width The width of the image.
153-
* @param height The height of the image.
154-
* @param randomize Whether to randomize the image or not.
152+
* @param width The width of the image. Defaults to `640`.
153+
* @param height The height of the image. Defaults to `480`.
154+
* @param randomize Whether to randomize the image or not. Defaults to `false`.
155155
*
156156
* @example
157157
* faker.image.business() // 'http://placeimg.com/640/480/business'
@@ -165,9 +165,9 @@ export class Image {
165165
/**
166166
* Generates a random cat image url.
167167
*
168-
* @param width The width of the image.
169-
* @param height The height of the image.
170-
* @param randomize Whether to randomize the image or not.
168+
* @param width The width of the image. Defaults to `640`.
169+
* @param height The height of the image. Defaults to `480`.
170+
* @param randomize Whether to randomize the image or not. Defaults to `false`.
171171
*
172172
* @example
173173
* faker.image.cats() // 'http://placeimg.com/640/480/cats'
@@ -181,9 +181,9 @@ export class Image {
181181
/**
182182
* Generates a random city image url.
183183
*
184-
* @param width The width of the image.
185-
* @param height The height of the image.
186-
* @param randomize Whether to randomize the image or not.
184+
* @param width The width of the image. Defaults to `640`.
185+
* @param height The height of the image. Defaults to `480`.
186+
* @param randomize Whether to randomize the image or not. Defaults to `false`.
187187
*
188188
* @example
189189
* faker.image.city() // 'http://placeimg.com/640/480/city'
@@ -197,9 +197,9 @@ export class Image {
197197
/**
198198
* Generates a random food image url.
199199
*
200-
* @param width The width of the image.
201-
* @param height The height of the image.
202-
* @param randomize Whether to randomize the image or not.
200+
* @param width The width of the image. Defaults to `640`.
201+
* @param height The height of the image. Defaults to `480`.
202+
* @param randomize Whether to randomize the image or not. Defaults to `false`.
203203
*
204204
* @example
205205
* faker.image.food() // 'http://placeimg.com/640/480/food'
@@ -213,9 +213,9 @@ export class Image {
213213
/**
214214
* Generates a random nightlife image url.
215215
*
216-
* @param width The width of the image.
217-
* @param height The height of the image.
218-
* @param randomize Whether to randomize the image or not.
216+
* @param width The width of the image. Defaults to `640`.
217+
* @param height The height of the image. Defaults to `480`.
218+
* @param randomize Whether to randomize the image or not. Defaults to `false`.
219219
*
220220
* @example
221221
* faker.image.nightlife() // 'http://placeimg.com/640/480/nightlife'
@@ -229,9 +229,9 @@ export class Image {
229229
/**
230230
* Generates a random fashion image url.
231231
*
232-
* @param width The width of the image.
233-
* @param height The height of the image.
234-
* @param randomize Whether to randomize the image or not.
232+
* @param width The width of the image. Defaults to `640`.
233+
* @param height The height of the image. Defaults to `480`.
234+
* @param randomize Whether to randomize the image or not. Defaults to `false`.
235235
*
236236
* @example
237237
* faker.image.fashion() // 'http://placeimg.com/640/480/fashion'
@@ -245,9 +245,9 @@ export class Image {
245245
/**
246246
* Generates a random people image url.
247247
*
248-
* @param width The width of the image.
249-
* @param height The height of the image.
250-
* @param randomize Whether to randomize the image or not.
248+
* @param width The width of the image. Defaults to `640`.
249+
* @param height The height of the image. Defaults to `480`.
250+
* @param randomize Whether to randomize the image or not. Defaults to `false`.
251251
*
252252
* @example
253253
* faker.image.people() // 'http://placeimg.com/640/480/people'
@@ -261,9 +261,9 @@ export class Image {
261261
/**
262262
* Generates a random nature image url.
263263
*
264-
* @param width The width of the image.
265-
* @param height The height of the image.
266-
* @param randomize Whether to randomize the image or not.
264+
* @param width The width of the image. Defaults to `640`.
265+
* @param height The height of the image. Defaults to `480`.
266+
* @param randomize Whether to randomize the image or not. Defaults to `false`.
267267
*
268268
* @example
269269
* faker.image.nature() // 'http://placeimg.com/640/480/nature'
@@ -277,9 +277,9 @@ export class Image {
277277
/**
278278
* Generates a random sports image url.
279279
*
280-
* @param width The width of the image.
281-
* @param height The height of the image.
282-
* @param randomize Whether to randomize the image or not.
280+
* @param width The width of the image. Defaults to `640`.
281+
* @param height The height of the image. Defaults to `480`.
282+
* @param randomize Whether to randomize the image or not. Defaults to `false`.
283283
*
284284
* @example
285285
* faker.image.sports() // 'http://placeimg.com/640/480/sports'
@@ -293,9 +293,9 @@ export class Image {
293293
/**
294294
* Generates a random technics image url.
295295
*
296-
* @param width The width of the image.
297-
* @param height The height of the image.
298-
* @param randomize Whether to randomize the image or not.
296+
* @param width The width of the image. Defaults to `640`.
297+
* @param height The height of the image. Defaults to `480`.
298+
* @param randomize Whether to randomize the image or not. Defaults to `false`.
299299
*
300300
* @example
301301
* faker.image.technics() // 'http://placeimg.com/640/480/technics'
@@ -309,9 +309,9 @@ export class Image {
309309
/**
310310
* Generates a random transport image url.
311311
*
312-
* @param width The width of the image.
313-
* @param height The height of the image.
314-
* @param randomize Whether to randomize the image or not.
312+
* @param width The width of the image. Defaults to `640`.
313+
* @param height The height of the image. Defaults to `480`.
314+
* @param randomize Whether to randomize the image or not. Defaults to `false`.
315315
*
316316
* @example
317317
* faker.image.transport() // 'http://placeimg.com/640/480/transport'
@@ -325,8 +325,8 @@ export class Image {
325325
/**
326326
* Generates a random data uri containing an svg image.
327327
*
328-
* @param width The width of the image.
329-
* @param height The height of the image.
328+
* @param width The width of the image. Defaults to `640`.
329+
* @param height The height of the image. Defaults to `480`.
330330
* @param color The color to use. Defaults to `grey`.
331331
*
332332
* @example

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export class Faker {
162162
/**
163163
* Set Faker's locale
164164
*
165-
* @param locale
165+
* @param locale The locale to set (e.g. `en` or `en_AU`, `en_AU_ocker`).
166166
*/
167167
setLocale(locale: UsableLocale): void {
168168
this.locale = locale;

src/internet.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ export class Internet {
319319
/**
320320
* Generates a random mac address.
321321
*
322-
* @param sep The optional separator to use. Can be either `':'`, `'-'` or `''`. Defaults to `':'`
322+
* @param sep The optional separator to use. Can be either `':'`, `'-'` or `''`. Defaults to `':'`.
323323
*
324324
* @example
325325
* faker.internet.mac() // '32:8e:2e:09:c6:05'
@@ -350,7 +350,7 @@ export class Internet {
350350
* @param len The length of the password to generate. Defaults to `15`.
351351
* @param memorable Whether the generated password should be memorable. Defaults to `false`.
352352
* @param pattern The pattern that all chars should match should match. Defaults to `/\w/`.
353-
* @param prefix The prefix to use. Defaults to `''`
353+
* @param prefix The prefix to use. Defaults to `''`.
354354
*
355355
* @example
356356
* faker.internet.password() // '89G1wJuBLbGziIs'

src/lorem.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class Lorem {
2222
/**
2323
* Generates a word of a specified length.
2424
*
25-
* @param length length of the word that should be returned. Defaults to a random length
25+
* @param length length of the word that should be returned. Defaults to a random length.
2626
*
2727
* @example
2828
* faker.lorem.word() // 'temporibus'

src/mersenne.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class Mersenne {
1919
}
2020

2121
/**
22-
* Generates a random number between [min, max)'.
22+
* Generates a random number between `[min, max)`.
2323
*
2424
* @param max The maximum number. Defaults to `0`.
2525
* @param min The minimum number. Defaults to `32768`. Required if `max` is set.

src/name.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export class Name {
216216
/**
217217
* Return a random gender.
218218
*
219-
* @param binary Whether to return only binary gender names. Defaults to false.
219+
* @param binary Whether to return only binary gender names. Defaults to `false`.
220220
*
221221
* @example
222222
* faker.name.gender() // 'Trans*Man'

0 commit comments

Comments
 (0)