use for-of statements to replace for and for-in
This commit is contained in:
+4
-9
@@ -1,24 +1,19 @@
|
||||
import { entries } from '@/core/base.ts';
|
||||
import type { IconInfo, IconInfoWithId } from '@/core/icon.ts';
|
||||
|
||||
export function getIconsInRows(allIconInfos: Record<string, IconInfo>, itemPerRow: number): IconInfoWithId[][] {
|
||||
const ret: IconInfoWithId[][] = [];
|
||||
let rowCount = 0;
|
||||
|
||||
for (const iconInfoId in allIconInfos) {
|
||||
if (!Object.prototype.hasOwnProperty.call(allIconInfos, iconInfoId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const iconInfo = allIconInfos[iconInfoId];
|
||||
|
||||
for (const [iconInfoId, iconInfo] of entries(allIconInfos)) {
|
||||
if (!ret[rowCount]) {
|
||||
ret[rowCount] = [];
|
||||
} else if (ret[rowCount] && ret[rowCount].length >= itemPerRow) {
|
||||
} else if (ret[rowCount] && ret[rowCount]!.length >= itemPerRow) {
|
||||
rowCount++;
|
||||
ret[rowCount] = [];
|
||||
}
|
||||
|
||||
ret[rowCount].push({
|
||||
ret[rowCount]!.push({
|
||||
id: iconInfoId,
|
||||
icon: iconInfo.icon
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user