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

refactor(company): deprecate suffix methods #1719

Merged
merged 2 commits into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/definitions/company.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export type CompanyDefinitions = LocaleEntry<{

/**
* Company/Business entity types.
*
* @deprecated Use `faker.company.name` instead.
*/
suffix: string[];
}>;
21 changes: 21 additions & 0 deletions src/modules/company/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Faker } from '../..';
import { deprecated } from '../../internal/deprecated';

/**
* Module to generate company related entries.
Expand All @@ -18,12 +19,22 @@ export class CompanyModule {
/**
* Returns an array with possible company name suffixes.
*
* @see faker.company.name()
*
* @example
* faker.company.suffixes() // [ 'Inc', 'and Sons', 'LLC', 'Group' ]
*
* @since 2.0.1
*
* @deprecated Use `faker.company.name` instead.
*/
suffixes(): string[] {
deprecated({
deprecated: 'faker.company.suffixes',
xDivisionByZerox marked this conversation as resolved.
Show resolved Hide resolved
proposed: 'faker.company.name',
since: '8.0',
until: '9.0',
});
// Don't want the source array exposed to modification, so return a copy
return this.faker.definitions.company.suffix.slice(0);
}
Expand All @@ -45,12 +56,22 @@ export class CompanyModule {
/**
* Returns a random company suffix.
*
* @see faker.company.name()
*
* @example
* faker.company.companySuffix() // 'and Sons'
*
* @since 2.0.1
*
* @deprecated Use `faker.company.name` instead.
*/
companySuffix(): string {
deprecated({
deprecated: 'faker.company.companySuffix',
proposed: 'faker.company.name',
since: '8.0',
until: '9.0',
});
return this.faker.helpers.arrayElement(this.suffixes());
}

Expand Down