Skip to content

Commit

Permalink
Merge branch 'next' into extend-locale
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT authored Mar 12, 2024
2 parents d5e4603 + a672d27 commit a0f5e20
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 316 deletions.
12 changes: 12 additions & 0 deletions docs/guide/upgrading_v9/2726.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
### Remove deprecated company methods

Removed deprecated company methods

| old | replacement |
| ----------------------------- | ----------------------------- |
| `faker.company.suffixes` | Part of `faker.company.name` |
| `faker.company.companySuffix` | Part of `faker.company.name` |
| `faker.company.bs` | `faker.company.buzzPhrase` |
| `faker.company.bsAdjective` | `faker.company.buzzAdjective` |
| `faker.company.bsBuzz` | `faker.company.buzzVerb` |
| `faker.company.bsNoun` | `faker.company.buzzNoun` |
7 changes: 7 additions & 0 deletions docs/guide/upgrading_v9/2738.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### Remove deprecated number parameter

Removed deprecated number parameter

| old | replacement |
| ----------------------------------- | ------------------------------------ |
| `faker.number.float({ precision })` | `faker.number.float({ multipleOf })` |
7 changes: 0 additions & 7 deletions src/definitions/company.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,4 @@ export type CompanyDefinition = LocaleEntry<{
* Catchphrase nouns that can be displayed to an end user.
*/
noun: string[];

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

/**
Expand All @@ -16,30 +15,6 @@ import { ModuleBase } from '../../internal/module-base';
* - For finance-related entries, use [`faker.finance`](https://fakerjs.dev/api/finance.html).
*/
export class CompanyModule extends ModuleBase {
/**
* Returns an array with possible company name suffixes.
*
* @see faker.company.name(): For generating a complete 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
// eslint-disable-next-line deprecation/deprecation
return [...this.faker.definitions.company.suffix];
}

/**
* Generates a random company name.
*
Expand All @@ -52,31 +27,6 @@ export class CompanyModule extends ModuleBase {
return this.faker.helpers.fake(this.faker.definitions.company.name_pattern);
}

/**
* Returns a random company suffix.
*
* @see faker.company.name(): For generating a complete 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(
// eslint-disable-next-line deprecation/deprecation
this.suffixes()
);
}

/**
* Generates a random catch phrase that can be displayed to an end user.
*
Expand All @@ -93,26 +43,6 @@ export class CompanyModule extends ModuleBase {
].join(' ');
}

/**
* Generates a random company bs phrase.
*
* @example
* faker.company.bs() // 'cultivate synergistic e-markets'
*
* @since 2.0.1
*
* @deprecated Use `faker.company.buzzPhrase` instead.
*/
bs(): string {
deprecated({
deprecated: 'faker.company.bs',
proposed: 'faker.company.buzzPhrase',
since: '8.0',
until: '9.0',
});
return this.buzzPhrase();
}

/**
* Generates a random buzz phrase that can be used to demonstrate data being viewed by a manager.
*
Expand Down Expand Up @@ -165,26 +95,6 @@ export class CompanyModule extends ModuleBase {
return this.faker.helpers.arrayElement(this.faker.definitions.company.noun);
}

/**
* Returns a random company bs adjective.
*
* @example
* faker.company.bsAdjective() // 'one-to-one'
*
* @since 2.0.1
*
* @deprecated Use `faker.company.buzzAdjective` instead.
*/
bsAdjective(): string {
deprecated({
deprecated: 'faker.company.bsAdjective',
proposed: 'faker.company.buzzAdjective',
since: '8.0',
until: '9.0',
});
return this.buzzAdjective();
}

/**
* Returns a random buzz adjective that can be used to demonstrate data being viewed by a manager.
*
Expand All @@ -199,26 +109,6 @@ export class CompanyModule extends ModuleBase {
);
}

/**
* Returns a random company bs buzz word.
*
* @example
* faker.company.bsBuzz() // 'empower'
*
* @since 2.0.1
*
* @deprecated Use `faker.company.buzzVerb` instead.
*/
bsBuzz(): string {
deprecated({
deprecated: 'faker.company.bsBuzz',
proposed: 'faker.company.buzzVerb',
since: '8.0',
until: '9.0',
});
return this.buzzVerb();
}

/**
* Returns a random buzz verb that can be used to demonstrate data being viewed by a manager.
*
Expand All @@ -233,26 +123,6 @@ export class CompanyModule extends ModuleBase {
);
}

/**
* Returns a random company bs noun.
*
* @example
* faker.company.bsNoun() // 'paradigms'
*
* @since 2.0.1
*
* @deprecated Use `faker.company.buzzNoun` instead.
*/
bsNoun(): string {
deprecated({
deprecated: 'faker.company.bsNoun',
proposed: 'faker.company.buzzNoun',
since: '8.0',
until: '9.0',
});
return this.buzzNoun();
}

/**
* Returns a random buzz noun that can be used to demonstrate data being viewed by a manager.
*
Expand Down
41 changes: 9 additions & 32 deletions src/modules/number/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { FakerError } from '../../errors/faker-error';
import { deprecated } from '../../internal/deprecated';
import { SimpleModuleBase } from '../../internal/module-base';

/**
Expand Down Expand Up @@ -90,13 +89,11 @@ export class NumberModule extends SimpleModuleBase {
*
* @param options Upper bound or options object.
* @param options.min Lower bound for generated number, inclusive. Defaults to `0.0`.
* @param options.max Upper bound for generated number, exclusive, unless `multipleOf`, `precision` or `fractionDigits` are passed. Defaults to `1.0`.
* @param options.precision Deprecated alias for `multipleOf`. Only one of `multipleOf`, `precision` or `fractionDigits` should be passed.
* @param options.multipleOf The generated number will be a multiple of this parameter. Only one of `multipleOf`, `precision` or `fractionDigits` should be passed.
* @param options.fractionDigits The maximum number of digits to appear after the decimal point, for example `2` will round to 2 decimal points. Only one of `multipleOf`, `precision` or `fractionDigits` should be passed.
* @param options.max Upper bound for generated number, exclusive, unless `multipleOf` or `fractionDigits` are passed. Defaults to `1.0`.
* @param options.multipleOf The generated number will be a multiple of this parameter. Only one of `multipleOf` or `fractionDigits` should be passed.
* @param options.fractionDigits The maximum number of digits to appear after the decimal point, for example `2` will round to 2 decimal points. Only one of `multipleOf` or `fractionDigits` should be passed.
*
* @throws When `min` is greater than `max`.
* @throws When `precision` is negative.
* @throws When `multipleOf` is negative.
* @throws When `fractionDigits` is negative.
* @throws When `fractionDigits` and `multipleOf` is passed in the same options object.
Expand Down Expand Up @@ -125,23 +122,17 @@ export class NumberModule extends SimpleModuleBase {
*/
min?: number;
/**
* Upper bound for generated number, exclusive, unless `multipleOf`, `precision` or `fractionDigits` are passed.
* Upper bound for generated number, exclusive, unless `multipleOf` or `fractionDigits` are passed.
*
* @default 1.0
*/
max?: number;
/**
* The maximum number of digits to appear after the decimal point, for example `2` will round to 2 decimal points. Only one of `multipleOf`, `precision` or `fractionDigits` should be passed.
* The maximum number of digits to appear after the decimal point, for example `2` will round to 2 decimal points. Only one of `multipleOf` or `fractionDigits` should be passed.
*/
fractionDigits?: number;
/**
* Deprecated alias for `multipleOf`. Only one of `multipleOf`, `precision` or `fractionDigits` should be passed.
*
* @deprecated Use `multipleOf` instead.
*/
precision?: number;
/**
* The generated number will be a multiple of this parameter. Only one of `multipleOf`, `precision` or `fractionDigits` should be passed.
* The generated number will be a multiple of this parameter. Only one of `multipleOf` or `fractionDigits` should be passed.
*/
multipleOf?: number;
} = {}
Expand All @@ -156,23 +147,10 @@ export class NumberModule extends SimpleModuleBase {
min = 0,
max = 1,
fractionDigits,
// eslint-disable-next-line deprecation/deprecation
precision,
// eslint-disable-next-line deprecation/deprecation
multipleOf: originalMultipleOf = precision,
multipleOf = precision ??
(fractionDigits == null ? undefined : 10 ** -fractionDigits),
multipleOf: originalMultipleOf,
multipleOf = fractionDigits == null ? undefined : 10 ** -fractionDigits,
} = options;

if (precision != null) {
deprecated({
deprecated: 'faker.number.float({ precision })',
proposed: 'faker.number.float({ multipleOf })',
since: '8.4',
until: '9.0',
});
}

if (max === min) {
return min;
}
Expand Down Expand Up @@ -201,8 +179,7 @@ export class NumberModule extends SimpleModuleBase {

if (multipleOf != null) {
if (multipleOf <= 0) {
// TODO @xDivisionByZerox: Clean up in v9.0
throw new FakerError(`multipleOf/precision should be greater than 0.`);
throw new FakerError(`multipleOf should be greater than 0.`);
}

const logPrecision = Math.log10(multipleOf);
Expand Down
4 changes: 0 additions & 4 deletions test/all-functional.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ type SkipConfig<TModule> = Partial<

const BROKEN_LOCALE_METHODS = {
// TODO @ST-DDT 2022-03-28: these are TODOs (usually broken locale files)
company: {
suffixes: ['az'],
companySuffix: ['az'],
},
date: {
between: '*',
betweens: '*',
Expand Down
33 changes: 0 additions & 33 deletions test/modules/__snapshots__/company.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,8 @@ exports[`company > 42 > catchPhraseDescriptor 1`] = `"explicit"`;

exports[`company > 42 > catchPhraseNoun 1`] = `"framework"`;

exports[`company > 42 > companySuffix 1`] = `"and Sons"`;

exports[`company > 42 > name 1`] = `"Wiegand - Reynolds"`;

exports[`company > 42 > suffixes 1`] = `
[
"Inc",
"and Sons",
"LLC",
"Group",
]
`;

exports[`company > 1211 > buzzAdjective 1`] = `"plug-and-play"`;

exports[`company > 1211 > buzzNoun 1`] = `"methodologies"`;
Expand All @@ -45,19 +34,8 @@ exports[`company > 1211 > catchPhraseDescriptor 1`] = `"upward-trending"`;

exports[`company > 1211 > catchPhraseNoun 1`] = `"system engine"`;

exports[`company > 1211 > companySuffix 1`] = `"Group"`;

exports[`company > 1211 > name 1`] = `"Trantow, Fahey and Zieme"`;

exports[`company > 1211 > suffixes 1`] = `
[
"Inc",
"and Sons",
"LLC",
"Group",
]
`;

exports[`company > 1337 > buzzAdjective 1`] = `"global"`;

exports[`company > 1337 > buzzNoun 1`] = `"ROI"`;
Expand All @@ -74,15 +52,4 @@ exports[`company > 1337 > catchPhraseDescriptor 1`] = `"demand-driven"`;

exports[`company > 1337 > catchPhraseNoun 1`] = `"data-warehouse"`;

exports[`company > 1337 > companySuffix 1`] = `"and Sons"`;

exports[`company > 1337 > name 1`] = `"Cronin and Sons"`;

exports[`company > 1337 > suffixes 1`] = `
[
"Inc",
"and Sons",
"LLC",
"Group",
]
`;
6 changes: 0 additions & 6 deletions test/modules/__snapshots__/number.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ exports[`number > 42 > float > with min, max and fractionDigits 1`] = `-0.4261`;

exports[`number > 42 > float > with min, max and multipleOf 1`] = `-0.4261`;

exports[`number > 42 > float > with min, max and precision 1`] = `-0.4261`;

exports[`number > 42 > float > with plain number 1`] = `1.49816047538945`;

exports[`number > 42 > hex > noArgs 1`] = `"5"`;
Expand Down Expand Up @@ -82,8 +80,6 @@ exports[`number > 1211 > float > with min, max and fractionDigits 1`] = `61.0658

exports[`number > 1211 > float > with min, max and multipleOf 1`] = `61.0658`;

exports[`number > 1211 > float > with min, max and precision 1`] = `61.0658`;

exports[`number > 1211 > float > with plain number 1`] = `3.714080615610337`;

exports[`number > 1211 > hex > noArgs 1`] = `"e"`;
Expand Down Expand Up @@ -134,8 +130,6 @@ exports[`number > 1337 > float > with min, max and fractionDigits 1`] = `-12.915

exports[`number > 1337 > float > with min, max and multipleOf 1`] = `-12.9153`;

exports[`number > 1337 > float > with min, max and precision 1`] = `-12.9153`;

exports[`number > 1337 > float > with plain number 1`] = `1.0480987000623267`;

exports[`number > 1337 > hex > noArgs 1`] = `"4"`;
Expand Down
Loading

0 comments on commit a0f5e20

Please sign in to comment.