code refactor

This commit is contained in:
MaysWind
2025-09-13 15:25:54 +08:00
parent 36d1e01008
commit ba72f421dc
2 changed files with 8 additions and 8 deletions
+6 -6
View File
@@ -21,27 +21,27 @@ export function* reversedItemAndIndex<T>(arr: T[]): Iterable<[T, number]> {
}
}
export function* entries<K extends string | number | symbol, V>(obj: Record<K, V>): Iterable<[K, V]> {
export function* entries<K extends string | number | symbol, V>(obj: Record<K, V>): Iterable<[string, V]> {
for (const key in obj) {
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
continue;
}
yield [key, obj[key]] as [K, V];
yield [key, obj[key]] as [string, V];
}
}
export function* keys<K extends string | number | symbol, V>(obj: Record<K, V>): Iterable<K> {
export function* keys<K extends string | number | symbol, V>(obj: Record<K, V>): Iterable<string> {
for (const key in obj) {
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
continue;
}
yield key as K;
yield key;
}
}
export function* keysIfValueEquals<K extends string | number | symbol, V>(obj: Record<K, V>, value: V): Iterable<K> {
export function* keysIfValueEquals<K extends string | number | symbol, V>(obj: Record<K, V>, value: V): Iterable<string> {
for (const key in obj) {
if (!Object.prototype.hasOwnProperty.call(obj, key)) {
continue;
@@ -51,7 +51,7 @@ export function* keysIfValueEquals<K extends string | number | symbol, V>(obj: R
continue;
}
yield key as K;
yield key;
}
}
+2 -2
View File
@@ -395,9 +395,9 @@ export function containsAvailableCategory(allTransactionCategories: Record<numbe
for (const [type, categoryType] of entries(allTransactionCategories)) {
if (showHidden) {
result[type] = categoryType.allCategories && categoryType.allCategories.length > 0;
result[parseInt(type)] = categoryType.allCategories && categoryType.allCategories.length > 0;
} else {
result[type] = categoryType.allVisibleCategoryCount > 0;
result[parseInt(type)] = categoryType.allVisibleCategoryCount > 0;
}
}