Skip to content

Commit 22a8cbc

Browse files
pkuczynskiST-DDTShinigami92
authored
chore: fix JSDoc comments in phone.ts (#397)
Co-authored-by: ST-DDT <[email protected]> Co-authored-by: Shinigami <[email protected]>
1 parent 1ddd366 commit 22a8cbc

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

src/phone.ts

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,46 @@ export class Phone {
1212
}
1313

1414
/**
15-
* phoneNumber
15+
* Generates a random phone number.
1616
*
17-
* @method faker.phone.phoneNumber
18-
* @param format
19-
* @memberOf faker.phone
17+
* @param format Format of the phone number. Defaults to `faker.phone.phoneFormats()`
18+
*
19+
* @example
20+
* faker.phone.phoneNumber() // '961-770-7727'
21+
* faker.phone.phoneNumber('501-###-###') // '501-039-841'
22+
* faker.phone.phoneNumber('+48 91 ### ## ##') // '+48 91 463 61 70'
2023
*/
24+
// TODO @pkuczynski 2022-02-01: simplify name to `number()`
2125
phoneNumber(format?: string): string {
22-
format ||= this.faker.phone.phoneFormats();
23-
return this.faker.helpers.replaceSymbolWithNumber(format);
26+
return this.faker.helpers.replaceSymbolWithNumber(
27+
format || this.phoneFormats()
28+
);
2429
}
2530

26-
// FIXME: this is strange passing in an array index.
2731
/**
28-
* phoneNumberFormat
32+
* Returns phone number in a format of the given index from `faker.definitions.phone_number.formats`.
33+
*
34+
* @param phoneFormatsArrayIndex Index in the `faker.definitions.phone_number.formats` array. Defaults to `0`.
2935
*
30-
* @method faker.phone.phoneFormatsArrayIndex
31-
* @param phoneFormatsArrayIndex
32-
* @memberOf faker.phone
36+
* @example
37+
* faker.phone.phoneNumberFormat() // '943-627-0355'
38+
* faker.phone.phoneNumberFormat(3) // '282.652.3201'
3339
*/
34-
phoneNumberFormat(phoneFormatsArrayIndex: number = 0): string {
40+
// FIXME @Shinigami 2022-01-14: this is strange passing in an array index
41+
// TODO @pkuczynski 2022-02-01: discuss removing this method as it tightly couples with localisation
42+
phoneNumberFormat(phoneFormatsArrayIndex = 0): string {
3543
return this.faker.helpers.replaceSymbolWithNumber(
3644
this.faker.definitions.phone_number.formats[phoneFormatsArrayIndex]
3745
);
3846
}
3947

4048
/**
41-
* phoneFormats
49+
* Returns a random phone number format.
4250
*
43-
* @method faker.phone.phoneFormats
51+
* @example
52+
* faker.phone.phoneFormats() // '!##.!##.####'
4453
*/
54+
// TODO @pkuczynski 2022-02-01: simplify name to `format()`
4555
phoneFormats(): string {
4656
return this.faker.random.arrayElement(
4757
this.faker.definitions.phone_number.formats

0 commit comments

Comments
 (0)