itube-specs 0.0.461 → 0.0.462
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -6,9 +6,11 @@ export function groupCategoriesByFirstLetter(
|
|
|
6
6
|
prop: string,
|
|
7
7
|
nonLetterKey = 'POST',
|
|
8
8
|
): Record<string, Array<ICategoryCard>> {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
9
|
+
const safeItems = Array.isArray(items) ? items : [];
|
|
10
|
+
return safeItems.reduce((acc, item) => {
|
|
11
|
+
const rawValue = String(item[prop as keyof IRawCategoryCard] ?? '').trim();
|
|
12
|
+
const firstLetter = rawValue.normalize().at(0)?.toUpperCase() ?? '';
|
|
13
|
+
const key = /^\p{L}$/u.test(firstLetter) ? firstLetter : nonLetterKey;
|
|
12
14
|
if (!acc[key]) {
|
|
13
15
|
acc[key] = [];
|
|
14
16
|
}
|