Skip to content

Commit

Permalink
fix for-of loops
Browse files Browse the repository at this point in the history
  • Loading branch information
miyaoka committed Oct 17, 2024
1 parent 0bf94f4 commit 4a88c32
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 27 deletions.
4 changes: 2 additions & 2 deletions src/components/menu/FilteringButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ function close() {
function selectAll() {
focusStore.isMultiSelectMode = true;
focusStore.multiSelectEventIdSet.clear();
eventListStore.filteredEventList.forEach((event) => {
for (const event of eventListStore.filteredEventList) {
focusStore.multiSelectEventIdSet.add(event.id);
});
}
}
</script>

Expand Down
8 changes: 5 additions & 3 deletions src/components/menu/channelFilter/ChannelFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ const rootNode = computed(() => {
function reset() {
storageStore.resetTalentFilter();
talentNodeEl.value?.querySelectorAll("input").forEach((input) => {
input.checked = false;
});
if (talentNodeEl.value) {
for (const input of talentNodeEl.value.querySelectorAll("input")) {
input.checked = false;
}
}
}
</script>

Expand Down
8 changes: 4 additions & 4 deletions src/components/menu/channelFilter/ChannelNode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,18 @@ function onGroupClick(e: Event) {
const group = e.target as HTMLInputElement;
emit("change");
children.value.names.forEach((name) => {
for (const name of children.value.names) {
storageStore.setTalentFilter(name, group.checked);
});
}
if (childNodeEl.value) {
const childInputs = [...childNodeEl.value.querySelectorAll("input")];
childInputs.forEach((input) => {
for (const input of childInputs) {
input.checked = group.checked;
// コンポーネントに変更を通知する
input.dispatchEvent(new Event("change"));
});
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/components/menu/keywordList/KeywordListPopover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ const hashtagList = computed(() => {
// 大文字小文字を区別せずにカウントし、一番多いものをキーにする
function createCountList(eventList: string[][]): KeywordItem[] {
const keywordMap: Map<string, Map<string, number>> = new Map();
eventList.forEach((keywordList) => {
keywordList.forEach((keyword) => {
for (const keywordList of eventList) {
for (const keyword of keywordList) {
// 小文字化したキーでカウント
const lowerKeyword = keyword.toLowerCase();
const countMap = keywordMap.get(lowerKeyword);
Expand All @@ -62,26 +62,26 @@ function createCountList(eventList: string[][]): KeywordItem[] {
} else {
keywordMap.set(lowerKeyword, new Map([[keyword, 1]]));
}
});
});
}
}
const resultList: KeywordItem[] = [];
keywordMap.forEach((countMap, _lowerItem) => {
for (const [lowerItem, countMap] of keywordMap.entries()) {
let totalCount = 0;
let key = "";
let maxCount = 0;
// キーワードごとのカウントを合計し、最大カウントを持つキーワードをキーにする
countMap.forEach((count, keyword) => {
for (const [keyword, count] of countMap.entries()) {
totalCount += count;
if (count > maxCount) {
maxCount = count;
key = keyword;
}
});
}
resultList.push({ value: key, count: totalCount });
});
}
return resultList.sort((a, b) => b.count - a.count);
}
Expand Down
9 changes: 5 additions & 4 deletions src/lib/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export function parseSearchString(input: string): SearchQuery {
const hashtagList: string[] = [];
const options: Record<string, string[]> = {};

let match;
let match = searchRegex.exec(input);

while ((match = searchRegex.exec(input)) !== null) {
while (match !== null) {
if (match.groups?.quoted) {
// クォートされた文字列から両端のクォートを削除してwordlistに追加
wordList.push(match.groups.quoted.slice(1, -1));
Expand All @@ -47,6 +47,7 @@ export function parseSearchString(input: string): SearchQuery {
// 単純な単語はwordlistに追加
wordList.push(match.groups.word);
}
match = searchRegex.exec(input);
}

return { wordList, hashtagList, options };
Expand Down Expand Up @@ -88,7 +89,7 @@ export function createSearchRegexp(queryArray: string[]): RegExp | null {
let currentAndPart: string[] = [];

// "or" を基準に配列を OR 条件ごとに分割
queryArray.forEach((term) => {
for (const term of queryArray) {
if (term.match(orRegExp)) {
// "or" が出てきたら、現在の AND 条件を保存し、新しい OR 部分を開始
orParts.push(currentAndPart);
Expand All @@ -99,7 +100,7 @@ export function createSearchRegexp(queryArray: string[]): RegExp | null {
// "or" 以外の部分は AND 条件として追加
currentAndPart.push(escapedTerm);
}
});
}
// 最後の AND 部分を保存
orParts.push(currentAndPart);

Expand Down
4 changes: 2 additions & 2 deletions src/lib/section.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ export function createDateSectionList(

// 時間ごとにイベントをグループ化
const liverEventMap = new Map<number, LiverEvent[]>();
liverEventList.forEach((event) => {
for (const event of liverEventList) {
const time = getHourTime(event.startAt);
if (!liverEventMap.has(time)) {
liverEventMap.set(time, []);
}
liverEventMap.get(time)?.push(event);
});
}

const dateSectionList: DateSection[] = [];

Expand Down
5 changes: 3 additions & 2 deletions src/lib/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ export function parseSegment(

// 文字列全体を順に解析する
let lastIndex = 0;
let match: RegExpExecArray | null;
while ((match = regex.exec(text)) !== null) {
let match = regex.exec(text);
while (match !== null) {
// マッチ部分の前にテキストがある場合、テキストとして追加
const beforeMatch = text.slice(lastIndex, match.index);
if (beforeMatch) {
Expand All @@ -150,6 +150,7 @@ export function parseSegment(
}

lastIndex = regex.lastIndex;
match = regex.exec(text);
}

// 最後のテキスト部分もセグメントとして追加
Expand Down
4 changes: 2 additions & 2 deletions src/store/eventListStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ export const useEventListStore = defineStore("eventListStore", () => {

// map更新
const eventMap = new Map<string, LiverEvent>();
newLiverEventList.forEach((liverEvent) => {
for (const liverEvent of newLiverEventList) {
eventMap.set(liverEvent.id, liverEvent);
});
}
liverEventMap.value = eventMap;

// 新着更新
Expand Down

0 comments on commit 4a88c32

Please sign in to comment.