Skip to content

Commit b119e29

Browse files
authored
Merge branch 'next' into chore/more-states-mk
2 parents d4b800f + 3dece09 commit b119e29

8 files changed

Lines changed: 246 additions & 177 deletions

File tree

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,16 @@
8888
},
8989
"devDependencies": {
9090
"@actions/github": "~5.1.1",
91-
"@algolia/client-search": "~4.18.0",
91+
"@algolia/client-search": "~4.19.1",
9292
"@types/markdown-it": "~12.2.3",
9393
"@types/node": "~20.4.1",
9494
"@types/prettier": "~2.7.3",
9595
"@types/react": "~18.2.15",
9696
"@types/sanitize-html": "~2.9.0",
9797
"@types/semver": "~7.5.0",
9898
"@types/validator": "~13.7.17",
99-
"@typescript-eslint/eslint-plugin": "~5.62.0",
100-
"@typescript-eslint/parser": "~5.62.0",
99+
"@typescript-eslint/eslint-plugin": "~6.1.0",
100+
"@typescript-eslint/parser": "~6.1.0",
101101
"@vitest/coverage-v8": "~0.33.0",
102102
"@vitest/ui": "~0.33.0",
103103
"@vueuse/core": "~10.2.1",
@@ -128,7 +128,7 @@
128128
"typescript": "~4.9.5",
129129
"validator": "~13.9.0",
130130
"vite": "~4.4.2",
131-
"vitepress": "1.0.0-beta.5",
131+
"vitepress": "1.0.0-beta.6",
132132
"vitest": "~0.33.0",
133133
"vue": "~3.3.4"
134134
},

pnpm-lock.yaml

Lines changed: 135 additions & 115 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 22 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,32 @@
11
export default [
2-
'An Giang',
3-
'Bà Rịa-Vũng Tàu',
4-
'Bạc Liêu',
5-
'Bắc Kạn',
6-
'Bắc Giang',
2+
'An Nhơn',
3+
'Biên Hòa',
4+
'Buôn Ma Thuột',
75
'Bắc Ninh',
8-
'Bến Tre',
9-
'Bình Dương',
10-
'Bình Định',
11-
'Bình Phước',
12-
'Bình Thuận',
136
'Cà Mau',
14-
'Cao Bằng',
157
'Cần Thơ',
16-
'Đà Nẵng',
17-
'Đắk Lắk',
18-
'Đắk Nông',
19-
'Điện Biên',
20-
'Đồng Nai',
21-
'Đồng Tháp',
22-
'Gia Lai',
23-
'Hà Giang',
24-
'Hà Nam',
25-
'Hà Nội',
26-
'Hà Tĩnh',
8+
'Haiphong',
9+
'Hanoi',
10+
'Ho Chi Minh City',
11+
'Huế',
2712
'Hải Dương',
28-
'Hải Phòng',
29-
'Hậu Giang',
30-
'Hòa Bình',
31-
'TP. Hồ Chí Minh',
32-
'Hưng Yên',
33-
'Khánh Hoà',
34-
'Kiên Giang',
35-
'Kon Tum',
36-
'Lai Châu',
37-
'Lạng Sơn',
38-
'Lào Cai',
39-
'Lâm Đồng',
40-
'Long An',
13+
'Long Xuyên',
14+
'Mỹ Tho',
4115
'Nam Định',
42-
'Nghệ An',
43-
'Ninh Bình',
44-
'Ninh Thuận',
45-
'Phú Thọ',
46-
'Phú Yên',
47-
'Quảng Bình',
48-
'Quảng Nam',
49-
'Quảng Ngãi',
50-
'Quảng Ninh',
51-
'Quảng Trị',
16+
'Nghi Sơn',
17+
'Nha Trang',
18+
'Phan Thiết',
19+
'Quy Nhơn',
20+
'Quảng Hà',
5221
'Sóc Trăng',
53-
'Sơn La',
54-
'Tây Ninh',
22+
'Thanh Hóa',
5523
'Thái Bình',
5624
'Thái Nguyên',
57-
'Thanh Hoá',
58-
'Thừa Thiên-Huế',
59-
'Tiền Giang',
60-
'Trà Vinh',
61-
'Tuyên Quang',
62-
'Vĩnh Long',
63-
'Vĩnh Phúc',
64-
'Yên Bái',
25+
'Thủ Dầu Một',
26+
'Thủ Đức',
27+
'Tân An',
28+
'Tân Uyên',
29+
'Vinh',
30+
'Việt Trì',
31+
'Vũng Tàu',
6532
];

src/locales/vi/location/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import city_pattern from './city_pattern';
88
import country from './country';
99
import default_country from './default_country';
1010
import postcode from './postcode';
11+
import state from './state';
1112
import street_pattern from './street_pattern';
1213

1314
const location: LocationDefinition = {
@@ -16,6 +17,7 @@ const location: LocationDefinition = {
1617
country,
1718
default_country,
1819
postcode,
20+
state,
1921
street_pattern,
2022
};
2123

src/locales/vi/location/state.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
export default [
2+
'An Giang',
3+
'Bà Rịa-Vũng Tàu',
4+
'Bắc Giang',
5+
'Bắc Kạn',
6+
'Bạc Liêu',
7+
'Bắc Ninh',
8+
'Bến Tre',
9+
'Bình Định',
10+
'Bình Dương',
11+
'Bình Phước',
12+
'Bình Thuận',
13+
'Cà Mau',
14+
'Cần Thơ',
15+
'Cao Bằng',
16+
'Đà Nẵng',
17+
'Đắk Lắk',
18+
'Đắk Nông',
19+
'Điện Biên',
20+
'Đồng Nai',
21+
'Đồng Tháp',
22+
'Gia Lai',
23+
'Hà Giang',
24+
'Hà Nam',
25+
'Hà Tây',
26+
'Hà Tĩnh',
27+
'Hải Dương',
28+
'Hải Phòng',
29+
'Hà Nội',
30+
'Hậu Giang',
31+
'Hồ Chí Minh',
32+
'Hòa Bình',
33+
'Hưng Yên',
34+
'Khánh Hòa',
35+
'Kiên Giang',
36+
'Kon Tum',
37+
'Lai Châu',
38+
'Lâm Đồng',
39+
'Lạng Sơn',
40+
'Lào Cai',
41+
'Long An',
42+
'Nam Định',
43+
'Nghệ An',
44+
'Ninh Bình',
45+
'Ninh Thuận',
46+
'Phú Thọ',
47+
'Phú Yên',
48+
'Quảng Bình',
49+
'Quảng Nam',
50+
'Quảng Ngãi',
51+
'Quảng Ninh',
52+
'Quảng Trị',
53+
'Sóc Trăng',
54+
'Sơn La',
55+
'Tây Ninh',
56+
'Thái Bình',
57+
'Thái Nguyên',
58+
'Thanh Hóa',
59+
'Thừa Thiên-Huế',
60+
'Tiền Giang',
61+
'Trà Vinh',
62+
'Tuyên Quang',
63+
'Vĩnh Long',
64+
'Vĩnh Phúc',
65+
'Yên Bái',
66+
];

src/modules/helpers/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,11 @@ export class HelpersModule {
649649
* and outputs a unique array of strings based on that source.
650650
* This method does not store the unique state between invocations.
651651
*
652+
* If there are not enough unique values to satisfy the length, if
653+
* the source is an array, it will only return as many items as are
654+
* in the array. If the source is a function, it will return after
655+
* a maximum number of attempts has been reached.
656+
*
652657
* @template T The type of the elements.
653658
*
654659
* @param source The strings to choose from or a function that generates a string.
@@ -671,8 +676,11 @@ export class HelpersModule {
671676
const set = new Set<T>();
672677
try {
673678
if (typeof source === 'function') {
674-
while (set.size < length) {
679+
const maxAttempts = 1000 * length;
680+
let attempts = 0;
681+
while (set.size < length && attempts < maxAttempts) {
675682
set.add(source());
683+
attempts++;
676684
}
677685
}
678686
} catch {

test/helpers.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,14 @@ describe('helpers', () => {
806806
expect(unique).toHaveLength(input.length);
807807
});
808808

809+
it('function with length longer than possible values returns', () => {
810+
const fn = () => faker.helpers.arrayElement(['a', 'b']);
811+
const length = 3;
812+
const unique = faker.helpers.uniqueArray(fn, length);
813+
expect(unique).not.toContainDuplicates();
814+
expect(unique).toHaveLength(2);
815+
});
816+
809817
it('works as expected when seeded', () => {
810818
const input = ['a', 'a', 'a', 'a', 'a', 'f', 'g', 'h', 'i', 'j'];
811819
const length = 5;

test/vitest-extensions.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ interface CustomMatchers {
2323
}
2424

2525
declare module 'vitest' {
26-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
2726
interface Assertion extends CustomMatchers {}
28-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
2927
interface AsymmetricMatchersContaining extends CustomMatchers {}
3028
}

0 commit comments

Comments
 (0)