From bece1a970a195fbe0f0cec4a8423d5f40bf1c3c1 Mon Sep 17 00:00:00 2001 From: mkelvers Date: Tue, 21 Apr 2026 01:22:04 +0200 Subject: [PATCH] refactor: extract parseClassList to shared utils --- static/anime.ts | 13 +------------ static/discover.ts | 13 +------------ static/utils.ts | 10 ++++++++++ 3 files changed, 12 insertions(+), 24 deletions(-) create mode 100644 static/utils.ts diff --git a/static/anime.ts b/static/anime.ts index 996fe12..fe1288f 100644 --- a/static/anime.ts +++ b/static/anime.ts @@ -1,15 +1,4 @@ -export {} - -const parseClassList = (value: string | null): string[] => { - if (!value) { - return [] - } - - return value - .split(' ') - .map((entry: string): string => entry.trim()) - .filter((entry: string): boolean => entry.length > 0) -} +import { parseClassList } from './utils' const setDropdownMenuState = (menu: HTMLElement, isOpen: boolean): void => { const openClasses = parseClassList(menu.getAttribute('data-dropdown-open-classes')) diff --git a/static/discover.ts b/static/discover.ts index e12c804..fdc2314 100644 --- a/static/discover.ts +++ b/static/discover.ts @@ -1,15 +1,4 @@ -export {} - -const parseClassList = (value: string | null): string[] => { - if (!value) { - return [] - } - - return value - .split(' ') - .map((entry: string): string => entry.trim()) - .filter((entry: string): boolean => entry.length > 0) -} +import { parseClassList } from './utils' const setActiveDiscoverTab = (clickedTab: Element): void => { const group = clickedTab.closest('[data-tab-group="discover"]') diff --git a/static/utils.ts b/static/utils.ts new file mode 100644 index 0000000..173b189 --- /dev/null +++ b/static/utils.ts @@ -0,0 +1,10 @@ +export const parseClassList = (value: string | null): string[] => { + if (!value) { + return [] + } + + return value + .split(' ') + .map((entry: string): string => entry.trim()) + .filter((entry: string): boolean => entry.length > 0) +}