Skip to content

Commit

Permalink
refactor(company): deprecate suffix methods (#1719)
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT authored Jan 9, 2023
1 parent 099e76c commit 1e7534e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
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',
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

0 comments on commit 1e7534e

Please sign in to comment.