From e1f26a6d2c79f3d9540f1890669631aca0fe5527 Mon Sep 17 00:00:00 2001 From: Guilherme Minozzi Date: Mon, 22 Aug 2022 15:53:08 -0300 Subject: feat(company): move name formats to locales (#1293) --- src/modules/company/index.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/modules') diff --git a/src/modules/company/index.ts b/src/modules/company/index.ts index 0a164fec..2a8b2db9 100644 --- a/src/modules/company/index.ts +++ b/src/modules/company/index.ts @@ -35,21 +35,24 @@ export class Company { * faker.company.name() // 'Zieme, Hauck and McClure' */ name(format?: number): string { - const formats = [ - '{{name.lastName}} {{company.companySuffix}}', - '{{name.lastName}} - {{name.lastName}}', - '{{name.lastName}}, {{name.lastName}} and {{name.lastName}}', - ]; - if (format != null) { deprecated({ deprecated: 'faker.company.name(format)', - proposed: 'faker.company.name()', + proposed: 'faker.company.name() or faker.helpers.fake(format)', since: '7.4', until: '8.0', }); } + // ToDo: This `staticFormats` pattern should be removed in the future. It is only used to maintain backwards compatibility. + const staticFormats = [ + '{{name.lastName}} {{company.companySuffix}}', + '{{name.lastName}} - {{name.lastName}}', + '{{name.lastName}}, {{name.lastName}} and {{name.lastName}}', + ]; + const formats = + this.faker.definitions.company.name_patterns ?? staticFormats; + if (typeof format !== 'number') { format = this.faker.datatype.number(formats.length - 1); } -- cgit v1.2.3