Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: change some phone methods #722

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/phone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ export class Phone {
* @param format Format of the phone number. Defaults to `faker.phone.phoneFormats()`.
*
* @example
* faker.phone.phoneNumber() // '961-770-7727'
* faker.phone.phoneNumber('501-###-###') // '501-039-841'
* faker.phone.phoneNumber('+48 91 ### ## ##') // '+48 91 463 61 70'
* faker.phone.number() // '961-770-7727'
* faker.phone.number('501-###-###') // '501-039-841'
* faker.phone.number('+48 91 ### ## ##') // '+48 91 463 61 70'
*/
// TODO @pkuczynski 2022-02-01: simplify name to `number()`
phoneNumber(format?: string): string {

number(format?: string): string {
return this.faker.helpers.replaceSymbolWithNumber(
format || this.phoneFormats()
format || this.formats()
);
}

Expand All @@ -52,10 +52,9 @@ export class Phone {
* Returns a random phone number format.
*
* @example
* faker.phone.phoneFormats() // '!##.!##.####'
* faker.phone.formats() // '!##.!##.####'
*/
// TODO @pkuczynski 2022-02-01: simplify name to `format()`
phoneFormats(): string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add aliases for these and call the deprecation function, so migrations are more smooth

formats(): string {
return this.faker.random.arrayElement(
this.faker.definitions.phone_number.formats
);
Expand Down