Skip to content

Commit

Permalink
Merge branch 'next' into fix/moduleResolution/Node
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT authored Mar 15, 2024
2 parents 2c2a216 + 2a50c76 commit 6f0f2fd
Show file tree
Hide file tree
Showing 11 changed files with 145 additions and 208 deletions.
7 changes: 7 additions & 0 deletions docs/guide/upgrading_v9/2752.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### Remove deprecated commerce method

Removed deprecated commerce method

| old | replacement |
| --------------------------------------------- | ------------------------------------------------- |
| `faker.commerce.price(min, max, dec, symbol)` | `faker.commerce.price({ min, max, dec, symbol })` |
9 changes: 9 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
[build]
publish = "docs/.vitepress/dist"
command = "pnpm docs:build:ci"
ignore = '''
if [ "$CONTEXT" != "deploy-preview" ]; then
# Always build when not a PR preview
exit 1;
else
# Otherwise check if something doc related changed.
git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF -- . \':!src/locale/\' \':!src/locales/\' \':!test/\' \':!package.json\' \':!pnpm-lock.yaml\' \':!.github/\'
fi
'''

# Alias for the main page
[[redirects]]
Expand Down
27 changes: 27 additions & 0 deletions src/locales/uz_UZ_latin/color/human.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export default [
'binofsha',
'fayruz rang',
"ko'k",
"ko'k-binofsha rang",
'krem rang',
'kulrang',
'kumush rang',
'limon rang',
'moviy',
'oq',
'osmon rang',
'olov rang',
'oltin rang',
'pushti',
'qizil',
'qizil-kulrang',
'qizil-siyoh binofsha',
"qizg'ish to'q sariq",
'qora',
'sariq',
'sariq-kulrang',
'siyoh binofsha',
"to'q sariq",
'yashil',
'zaytun rang',
];
12 changes: 12 additions & 0 deletions src/locales/uz_UZ_latin/color/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* This file is automatically generated.
* Run 'pnpm run generate:locales' to update.
*/
import type { ColorDefinition } from '../../..';
import human from './human';

const color: ColorDefinition = {
human,
};

export default color;
14 changes: 14 additions & 0 deletions src/locales/uz_UZ_latin/date/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* This file is automatically generated.
* Run 'pnpm run generate:locales' to update.
*/
import type { DateDefinition } from '../../..';
import month from './month';
import weekday from './weekday';

const date: DateDefinition = {
month,
weekday,
};

export default date;
30 changes: 30 additions & 0 deletions src/locales/uz_UZ_latin/date/month.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export default {
wide: [
'Yanvar',
'Fevral',
'Mart',
'Aprel',
'May',
'Iyun',
'Iyul',
'Avgust',
'Sentyabr',
'Oktyabr',
'Noyabr',
'Dekabr',
],
abbr: [
'Yan.',
'Fev.',
'Mar',
'Apr.',
'May',
'Iyn',
'Iyl',
'Avg.',
'Sen.',
'Okt.',
'Noy.',
'Dek.',
],
};
12 changes: 12 additions & 0 deletions src/locales/uz_UZ_latin/date/weekday.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default {
wide: [
'Yakshanba',
'Dushanba',
'Seshanba',
'Chorshanba',
'Payshanba',
'Juma',
'Shanba',
],
abbr: ['Ya', 'Du', 'Se', 'Ch', 'Pa', 'Ju', 'Sh'],
};
4 changes: 4 additions & 0 deletions src/locales/uz_UZ_latin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
* Run 'pnpm run generate:locales' to update.
*/
import type { LocaleDefinition } from '../..';
import color from './color';
import date from './date';
import metadata from './metadata';
import person from './person';

const uz_UZ_latin: LocaleDefinition = {
color,
date,
metadata,
person,
};
Expand Down
195 changes: 26 additions & 169 deletions src/modules/commerce/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 { ModuleBase } from '../../internal/module-base';

// Source for official prefixes: https://www.isbn-international.org/range_file_generation
Expand Down Expand Up @@ -138,176 +137,34 @@ export class CommerceModule extends ModuleBase {
*
* @since 3.0.0
*/
price(options?: {
/**
* The minimum price.
*
* @default 1
*/
min?: number;
/**
* The maximum price.
*
* @default 1000
*/
max?: number;
/**
* The number of decimal places.
*
* @default 2
*/
dec?: number;
/**
* The currency value to use.
*
* @default ''
*/
symbol?: string;
}): string;
/**
* Generates a price between min and max (inclusive).
*
* To better represent real-world prices, when `options.dec` is greater than `0`, the final decimal digit in the returned string will be generated as follows:
*
* - 50% of the time: `9`
* - 30% of the time: `5`
* - 10% of the time: `0`
* - 10% of the time: a random digit from `0` to `9`
*
* @param min The minimum price. Defaults to `1`.
* @param max The maximum price. Defaults to `1000`.
* @param dec The number of decimal places. Defaults to `2`.
* @param symbol The currency value to use. Defaults to `''`.
*
* @example
* faker.commerce.price() // 828.07
* faker.commerce.price(100) // 904.19
* faker.commerce.price(100, 200) // 154.55
* faker.commerce.price(100, 200, 0) // 133
* faker.commerce.price(100, 200, 0, '$') // $114
*
* @since 3.0.0
*
* @deprecated Use `faker.commerce.price({ min, max, dec, symbol })` instead.
*/
price(min?: number, max?: number, dec?: number, symbol?: string): string;
/**
* Generates a price between min and max (inclusive).
*
* To better represent real-world prices, when `options.dec` is greater than `0`, the final decimal digit in the returned string will be generated as follows:
*
* - 50% of the time: `9`
* - 30% of the time: `5`
* - 10% of the time: `0`
* - 10% of the time: a random digit from `0` to `9`
*
* @param options The minimum price or an options object.
* @param options.min The minimum price. Defaults to `1`.
* @param options.max The maximum price. Defaults to `1000`.
* @param options.dec The number of decimal places. Defaults to `2`.
* @param options.symbol The currency value to use. Defaults to `''`.
* @param legacyMax The maximum price. This argument is deprecated. Defaults to `1000`.
* @param legacyDec The number of decimal places. This argument is deprecated. Defaults to `2`.
* @param legacySymbol The currency value to use. This argument is deprecated. Defaults to `''`.
*
* @example
* faker.commerce.price() // 828.07
* faker.commerce.price({ min: 100 }) // 904.19
* faker.commerce.price({ min: 100, max: 200 }) // 154.55
* faker.commerce.price({ min: 100, max: 200, dec: 0 }) // 133
* faker.commerce.price({ min: 100, max: 200, dec: 0, symbol: '$' }) // $114
*
* @since 3.0.0
*/
price(
options?:
| number
| {
/**
* The minimum price.
*
* @default 1
*/
min?: number;
/**
* The maximum price.
*
* @default 1000
*/
max?: number;
/**
* The number of decimal places.
*
* @default 2
*/
dec?: number;
/**
* The currency value to use.
*
* @default ''
*/
symbol?: string;
},
legacyMax?: number,
legacyDec?: number,
legacySymbol?: string
): string;
/**
* Generates a price between min and max (inclusive).
*
* To better represent real-world prices, when `options.dec` is greater than `0`, the final decimal digit in the returned string will be generated as follows:
*
* - 50% of the time: `9`
* - 30% of the time: `5`
* - 10% of the time: `0`
* - 10% of the time: a random digit from `0` to `9`
*
* @param options The minimum price or an options object.
* @param options.min The minimum price. Defaults to `1`.
* @param options.max The maximum price. Defaults to `1000`.
* @param options.dec The number of decimal places. Defaults to `2`.
* @param options.symbol The currency value to use. Defaults to `''`.
* @param legacyMax The maximum price. This argument is deprecated. Defaults to `1000`.
* @param legacyDec The number of decimal places. This argument is deprecated. Defaults to `2`.
* @param legacySymbol The currency value to use. This argument is deprecated. Defaults to `''`.
*
* @example
* faker.commerce.price() // 828.07
* faker.commerce.price({ min: 100 }) // 904.19
* faker.commerce.price({ min: 100, max: 200 }) // 154.55
* faker.commerce.price({ min: 100, max: 200, dec: 0 }) // 133
* faker.commerce.price({ min: 100, max: 200, dec: 0, symbol: '$' }) // $114
*
* @since 3.0.0
*/
price(
options:
| number
| {
min?: number;
max?: number;
dec?: number;
symbol?: string;
} = {},
legacyMax: number = 1000,
legacyDec: number = 2,
legacySymbol: string = ''
options: {
/**
* The minimum price.
*
* @default 1
*/
min?: number;
/**
* The maximum price.
*
* @default 1000
*/
max?: number;
/**
* The number of decimal places.
*
* @default 2
*/
dec?: number;
/**
* The currency value to use.
*
* @default ''
*/
symbol?: string;
} = {}
): string {
if (typeof options === 'number') {
deprecated({
deprecated: 'faker.commerce.price(min, max, dec, symbol)',
proposed: 'faker.commerce.price({ min, max, dec, symbol })',
since: '8.0',
until: '9.0',
});
options = {
min: options,
dec: legacyDec,
max: legacyMax,
symbol: legacySymbol,
};
}

const { dec = 2, max = 1000, min = 1, symbol = '' } = options;

if (min < 0 || max < 0) {
Expand Down
Loading

0 comments on commit 6f0f2fd

Please sign in to comment.